RE: How to avoid this greedy match?



Hi,

I don't think '<' or '>' are meta characters in regular expression match.

"<>" is reserved for opening the files given at command line argument.

Aside from that, consider using [^<]* and [^>]* in place of .*
If we use "[^<]* and [^>]*", regular expression will fail to match pattern like "<script>xxx</script>zzz<script>>>222<></script>" [Pattern having angular brackets beside 222.

As we don't know what can precede or succeed '222', it's better we don't give any restriction in the regular expression.

~Ajay

-----Original Message-----
From: anexpert@xxxxxxxxx [mailto:anexpert@xxxxxxxxx]On Behalf Of yitzle
Sent: Tuesday, January 29, 2008 11:53 AM
To: Nagrale, Ajay
Cc: News Howardz; beginners@xxxxxxxx
Subject: Re: How to avoid this greedy match?


I'm not sure how it works, but I think <> or \<\> is a RegEx reserved
character for word matching.
Aside from that, consider using [^<]* and [^>]* in place of .*
.



Relevant Pages

  • Re: Ruby regexp Match
    ... spot where my Perl script is doing a regular expression match on some ... text pulled from a webpage. ... regular expression which represented the data I wanted, ...
    (comp.lang.ruby)
  • Re: sed command to replace text with blank spaces
    ... > is somewhat complicated and would involve isolating the ... > regular expression match, ...
    (comp.unix.shell)