tags:

views:

60

answers:

1

Can some one help me create a regular expression in C#.net to add target="_blank" to all tag links in my content? If the link already has a target set then replace it with "_blank". The purpose is to open all links in my content in a new window.

Appreciate your help

-dotnet rocks

A: 
RegEx.Replace(inputString, "<(a)([^>]+)>", "<$1 target=""_blank""$2>")
Brandon Montgomery
Good quick answer, but you don't account for target="_blank" or target="something else" already being in the regex. Something to think about.
Platinum Azure