开发者

What matches this regex?

开发者 https://www.devze.com 2023-01-26 17:18 出处:网络
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.

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 behaviou开发者_StackOverflow中文版r here is...


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


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


\e is usually equal to \033.


It's the escape sequence (0x1B).

See non printable characters section here.


I think you should use

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

to match "what\ever"

0

精彩评论

暂无评论...
验证码 换一张
取 消