Colin
Colin

Reputation:

VB.NET Regex.replace <>

Im pretty new to regex and im having trouble using VB and regex.

Im trying to remove a <span ....> comment and replace it with <b>

so far ive got this:

Regex.Replace(text, "<span[^>]*>", "<b>", RegexOptions.IgnoreCase)

This correctly matches the span comment but when it replaces it with the string it strips the <> and just leaves the "b". Ive tried delimiting the \<b\> but it just skips the \ and still removes the <> to leave \b\.

Can anyone cure my ignorance and tell me what im doing wrong.

Cheers

Upvotes: 1

Views: 1464

Answers (1)

Steven
Steven

Reputation: 3843

You need to escape the slash itself in order for regex to catch it: "\\"

Upvotes: 1

Related Questions