Using \b in C# regular expressions doesn't work?
Posted
by Nikhil
on Stack Overflow
See other posts from Stack Overflow
or by Nikhil
Published on 2010-03-15T17:59:00Z
Indexed on
2010/03/15
17:59 UTC
Read the original article
Hit count: 294
I am wondering why the following regex does not match.
string query = "\"1 2\" 3";
string pattern = string.Format(@"\b{0}\b", Regex.Escape("\"1 2\""));
string repl = Regex.Replace(query, pattern, "", RegexOptions.CultureInvariant);
Note that if I remove the word boundary characters (\b) from pattern
, it matches fine. Is there something about '\b' that might be tripping this up?
© Stack Overflow or respective owner