How can I avoid a specific string pattern from being replaced by Regex.replace ()

Posted by Taz on Stack Overflow See other posts from Stack Overflow or by Taz
Published on 2010-05-06T10:12:37Z Indexed on 2010/05/06 10:38 UTC
Read the original article Hit count: 262

Filed under:
|
|

I have a string like
Pakistan, officially the <a href="Page.aspx?Link=Islamic Republic of Pakistan">Islamic Republic of Pakistan</a>

Now I am using
System.Text.RegularExpressions.Regex.Replace(inputText, "(\\bPakistan\\b)", "something"); to replace Pakistan outside the tags. But I don't want to replace Pakistan occurring within the <a></a> tags.

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex