Regex help

P

powerranger

I'd like to replace any html tags containing "< >" with a space. For
example, <TR VALIGN=TOP>, I'd like to replace that with a space. Is
there a way to do this? Thanks.
 
R

Ross Donald

Hi,

The expression would be something like this:

\<(.+?)\>

Group 1 will be the contents of the html tag without the brackets.

e.g.
// C#
string _InputText = "example, <TR VALIGN=TOP>, I'd like to replace";

Regex MyRegex = new Regex(@"\<(.+?)\>", RegexOptions.IgnoreCase);
string nohtmltags = MyRegex.Replace(_InputText, " ");

Another one would be

\<([^>]+)\>

explanation:
Match '<'
Match one or more characters but dont match '>'
Match '>'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top