开发者

Simple regex word question

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"
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜