Regex help

Discussion in 'ASP .Net' started by powerranger, Jun 24, 2003.

  1. powerranger

    powerranger Guest

    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.
    powerranger, Jun 24, 2003
    #1
    1. Advertising

  2. powerranger

    Ross Donald Guest

    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 '>'

    --
    Ross Donald
    RAD Software
    http://www.radsoftware.com.au


    "powerranger" <> wrote in message
    news:...
    > 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.
    Ross Donald, Jun 26, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SmViQnVzaGVsbA==?=

    Is ASP Validator Regex Engine Same As VS2003 Find Regex Engine?

    =?Utf-8?B?SmViQnVzaGVsbA==?=, Oct 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    695
    =?Utf-8?B?SmViQnVzaGVsbA==?=
    Oct 22, 2005
  2. Rick Venter

    perl regex to java regex

    Rick Venter, Oct 29, 2003, in forum: Java
    Replies:
    5
    Views:
    1,619
    Ant...
    Nov 6, 2003
  3. Replies:
    2
    Views:
    594
  4. Xah Lee
    Replies:
    1
    Views:
    937
    Ilias Lazaridis
    Sep 22, 2006
  5. Replies:
    3
    Views:
    744
    Reedick, Andrew
    Jul 1, 2008
Loading...

Share This Page