mpen
mpen

Reputation: 282845

What matches this regex?

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...

Upvotes: 2

Views: 268

Answers (5)

dhinesh
dhinesh

Reputation: 4764

I think you should use

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

to match "what\ever"

Upvotes: -1

Simone
Simone

Reputation: 11797

It's the escape sequence (0x1B).

See non printable characters section here.

Upvotes: 2

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798566

\e is usually equal to \033.

Upvotes: 2

Kev Hunter
Kev Hunter

Reputation: 2625

\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.

Upvotes: 3

lijie
lijie

Reputation: 4871

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

Upvotes: 7

Related Questions