I have the regex:
TheComment = Regex.Replace(TheComment, "(\\@" + r + "\b)", "<span style=\"background:yellow;font-weight:bold;\">@" + ThisUser.Username + "</span>", RegexOptions.IgnoreCase);
This is an example pattern
(\\@to\b)
I want this to match @To
but not @Tom
. At the moment it's not matching, if I strip the \b
away it works but it matches @Tom
as well w开发者_开发知识库hich is musn't.
You have to escape \
and not @
. Plus, you got to move \b
out of the selection.
@"(@" + r + @")\b"
精彩评论