Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Regex help

    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 Guest

  2. Similar Questions and Discussions

    1. REGEX help pls
      in the regex buddy they are explaining: "Be careful when using the negated shorthands inside square brackets. is not the same as . The latter...
    2. Regex..
      Could some good samaritan help me out with this pls... I am trying to find a regular expression for the below string.. ExchangeName =...
    3. regex, is this possible?
      Hi! I am trying to break down the following: printf("numsteps=%d i=%d im=%g vfr=%g \n",numsteps,i,imeas,vforce); into "numsteps= numsteps ...
    4. Need help with regex
      > I have a directory of files that I want to move to another directory.
    5. IP regex?
      Gareth Glaccum wrote: How about using m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ and testing $1 - $4 for compliance? Much cleaner. -- Cheers,
  3. #2

    Default Re: Regex help

    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
    [url]http://www.radsoftware.com.au[/url]


    "powerranger" <tangolp@yahoo.com> wrote in message
    news:13bc95e0.0306241441.5e701435@posting.google.c om...
    > 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 Guest

  4. #3

    Default regex help

    This isnt specifically a perl question, I'm running squid, and running it
    through a regex. The question, I'm trying to filter out some spam/ad sites
    using regex, I started with the "Penis Enlarging" websites.

    I want to match "penis" and "enlarge" in any order, So far I've got

    [(penis)(large)(.*)]
    I've also tried [(penis)(large)(.*)]{1,} with no luck. Anyone a regex king
    that could help me out? :)


    --
    "Prayer has no place in Public School, just like facts have no place in
    organized religion." --The Simpsons


    mdew Guest

  5. #4

    Default Re: regex help

    mdew wrote:
    > This isnt specifically a perl question [...]

    So why the fook are you asking it here!?


    --
    Cheers,
    Bernard
    --
    echo 42|perl -pe '$#="Just another Perl hacker,"'

    Bernard El-Hagin Guest

  6. #5

    Default Re: regex help

    mdew <not@home.com> wrote in comp.lang.perl.misc:
    > This isnt specifically a perl question, I'm running squid, and running it
    > through a regex. The question, I'm trying to filter out some spam/ad sites
    > using regex, I started with the "Penis Enlarging" websites.
    >
    > I want to match "penis" and "enlarge" in any order, So far I've got
    >
    > [(penis)(large)(.*)]
    > I've also tried [(penis)(large)(.*)]{1,} with no luck. Anyone a regex king
    > that could help me out? :)
    Matching "this" or "that" in any order *can* be done in a single
    (Perl-) regex, but it's a nuisance and doesn't scale. Use an extra
    regex for each word.

    Anno
    Anno Siegel Guest

  7. #6

    Default Re: regex help

    On Fri, 05 Sep 2003 12:17:38 +0000, Anno Siegel wrote:
    > mdew <not@home.com> wrote in comp.lang.perl.misc:
    >> This isnt specifically a perl question, I'm running squid, and running
    >> it through a regex. The question, I'm trying to filter out some spam/ad
    >> sites using regex, I started with the "Penis Enlarging" websites.
    >>
    >> I want to match "penis" and "enlarge" in any order, So far I've got
    >>
    >> [(penis)(large)(.*)]
    >> I've also tried [(penis)(large)(.*)]{1,} with no luck. Anyone a regex
    >> king that could help me out? :)
    >
    > Matching "this" or "that" in any order *can* be done in a single (Perl-)
    > regex, but it's a nuisance and doesn't scale. Use an extra regex for
    > each word.
    I'm testing to 2 possibilities, to prevent legit websites from being
    unnecessarily filtered, I'm thinking of *penis*enlarge* and in reverse
    *enlarge*penis*. Whats the proper regex way of doing this?

    --
    "Prayer has no place in Public School, just like facts have no place in
    organized religion." --The Simpsons


    mdew Guest

  8. #7

    Default Re: regex help

    mdew <not@home.com> wrote:
    > On Fri, 05 Sep 2003 12:17:38 +0000, Anno Siegel wrote:
    >> mdew <not@home.com> wrote in comp.lang.perl.misc:
    >>>
    >>> I want to match "penis" and "enlarge" in any order, So far I've got
    >>>
    >>> [(penis)(large)(.*)]
    >>> I've also tried [(penis)(large)(.*)]{1,} with no luck. Anyone a regex
    >>> king that could help me out? :)
    >>
    >> Matching "this" or "that" in any order *can* be done in a single (Perl-)
    >> regex, but it's a nuisance and doesn't scale. Use an extra regex for
    >> each word.
    >
    > I'm testing to 2 possibilities, to prevent legit websites from being
    > unnecessarily filtered, I'm thinking of *penis*enlarge* and in reverse
    > *enlarge*penis*. Whats the proper regex way of doing this?
    print "Spam!" if (/penis enlarge/i || /enlarge penis/i );

    --
    Vlad
    Vlad Tepes Guest

  9. #8

    Default Re: regex help

    On Sat, 06 Sep 2003 00:48:45 +1200, mdew <not@home.com> wrote:
    > On Fri, 05 Sep 2003 12:17:38 +0000, Anno Siegel wrote:
    >
    >> Matching "this" or "that" in any order *can* be done in a single (Perl-)
    >> regex, but it's a nuisance and doesn't scale. Use an extra regex for
    >> each word.
    >
    > I'm testing to 2 possibilities, to prevent legit websites from being
    > unnecessarily filtered, I'm thinking of *penis*enlarge* and in reverse
    > *enlarge*penis*. Whats the proper regex way of doing this?
    /enlarge/ || /penis/

    Your just trying to make us use rudy words (like "enlarge") aren't you :)

    --
    Sam Holden

    Sam Holden Guest

  10. #9

    Default Re: regex help

    mdew (not@home.com) wrote on MMMDCLVII September MCMXCIII in
    <URL:news:pan.2003.09.05.12.06.47.20627@home.com >:
    [] This isnt specifically a perl question,

    Then you shouldn't be asking here.

    Goodbye.


    Abigail
    --
    perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=> CD=>(
    0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29 =>X=>IX=>0=>0=>0=>V=>IV=>0=>0
    =>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$ r[$#r];$=-=$#r}for(;
    !$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCI II=>=>=>=>=>=>=>=>'
    Abigail Guest

  11. #10

    Default Re: regex help

    On 5 Sep 2003 12:53:46 GMT, Sam Holden <sholden@flexal.cs.usyd.edu.au> wrote:
    > On Sat, 06 Sep 2003 00:48:45 +1200, mdew <not@home.com> wrote:
    >> On Fri, 05 Sep 2003 12:17:38 +0000, Anno Siegel wrote:
    >>
    >>> Matching "this" or "that" in any order *can* be done in a single (Perl-)
    >>> regex, but it's a nuisance and doesn't scale. Use an extra regex for
    >>> each word.
    >>
    >> I'm testing to 2 possibilities, to prevent legit websites from being
    >> unnecessarily filtered, I'm thinking of *penis*enlarge* and in reverse
    >> *enlarge*penis*. Whats the proper regex way of doing this?
    >
    > /enlarge/ || /penis/
    /enlarge/ && /penis/

    Must stop posting late at night :(

    --
    Sam Holden

    Sam Holden Guest

  12. #11

    Default Re: regex help

    On Fri, 05 Sep 2003 12:53:46 +0000, Sam Holden wrote:
    > On Sat, 06 Sep 2003 00:48:45 +1200, mdew <not@home.com> wrote:
    >> On Fri, 05 Sep 2003 12:17:38 +0000, Anno Siegel wrote:
    >>
    >>> Matching "this" or "that" in any order *can* be done in a single (Perl-)
    >>> regex, but it's a nuisance and doesn't scale. Use an extra regex for
    >>> each word.
    >>
    >> I'm testing to 2 possibilities, to prevent legit websites from being
    >> unnecessarily filtered, I'm thinking of *penis*enlarge* and in reverse
    >> *enlarge*penis*. Whats the proper regex way of doing this?
    >
    > /enlarge/ || /penis/
    >
    > Your just trying to make us use rudy words (like "enlarge") aren't you :)
    I'm no big perl guru, but doesnt || mean "OR", so any url's with "enlarge"
    in the title would get mark as spam? how about,

    (enlarge AND penis) OR (penis AND enlarge)

    the OR could be ditched, for say to regex, am i looking at this the right
    way?


    --
    "Prayer has no place in Public School, just like facts have no place in
    organized religion." --The Simpsons


    mdew Guest

  13. #12

    Default Regex help

    Guys Iam parsing three wbsites for specific links using three different regex.
    I have tested all three regex using a regex tester and they all give me the
    desired results. My regex are located in an XML doc and I have a seperate CF
    file that reads the doc and uses the regex from the XML. However when I place
    the parse results into an array one of the regex returns nothing. I dont think
    my regex is wrong as I have tested it could someone please take a look? Here is
    my regex: href={{:punct:]]+id(.*?)[[:digit:]]+[[:punct:]] Here is an example of
    the html i am parsing: <td><a hre='?id=3400305'> Thanks in advance

    samb1 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139