Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stroustrup regex \e

Tags:

c++

regex

In A Tour of C++, on page 83, Stroustrup provides the following regular expression:

R"((\ew+))"

Nowhere in the book is \e defined, and I can't find anything about it on the Internet. What does \e represent in a regular expression?

like image 927
Argent Avatar asked Jun 21 '26 14:06

Argent


1 Answers

It's just a typo by Stroustrup. \e doesn't have any special meaning in regular expressions and doesn't make sense in the context.

If you were to actually compile the example code on the page using

R"((\ew+))"

wouldn't print anything at all. He probably just wanted to use

R"((\w+))"

a capture group of 1 or more word characters, which matches the shown output.

His original regex compiled

Compiled after removing the extra 'e'

like image 127
AliciaBytes Avatar answered Jun 23 '26 04:06

AliciaBytes