views:

413

answers:

1

Hi

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

+1  A: 

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

shambleh