2

This compiles and executes:

 var re = new Regex(@"what\ever");

But I can't find anything that matches it. whatever, what\ever and what\\ever all fail to match.

\e isn't a valid escape sequence AFAIK, so I'm not sure what the intended behaviour here is...

mpen
  • 237,624
  • 230
  • 766
  • 1,119

5 Answers5

7

I think \e matches the "Escape" character (ASCII code 27). Hence it should match "what\x1bver"

lijie
  • 4,621
  • 19
  • 25
  • This answer has been added to the [Stack Overflow Regular Expression FAQ](http://stackoverflow.com/a/22944075/2736496), under "Escape Sequences". – aliteralmind Apr 10 '14 at 01:06
3

\e is the escape control character

you can use a free tool called The Regulator which has built in intellisense which helps for things like this.

Kev Hunter
  • 2,365
  • 4
  • 22
  • 37
2

\e is usually equal to \033.

Ignacio Vazquez-Abrams
  • 699,552
  • 132
  • 1,235
  • 1,283
2

It's the escape sequence (0x1B).

See non printable characters section here.

Simone
  • 10,912
  • 1
  • 26
  • 39
-1

I think you should use

var re = new Regex(@"[what\ever]");

to match "what\ever"

dhinesh
  • 4,410
  • 2
  • 21
  • 43
  • That looks like a character class to me.... not at all what I want. That will match *anything* with 1 or more of those letters in it. Not to mention this was only an example... I have no intention of matching `what\ever` (if I did, I'd use `what\\ever`) – mpen Nov 25 '10 at 10:54
  • `-1` for giving a wrong answer. [See this explanation](http://rick.measham.id.au/paste/explain.pl?regex=%5Bwhat%5Cever%5D) – HamZa Apr 06 '14 at 08:33