[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Searching for delimiters using regular expressions



Jonah Benton <jonah@arcus.net> writes:
>For instance, I want to successively find the <> delimited strings inside of
>"This is <a phrase> that lets you <another phrase> blah blah blah..." and
>replace them with some text depending on the contents inside the delimiters
><>. What I want is a single regexp that returns to me the contents inside
>the <>, and a way to iterate across a body of text. 
>
>What I've gotten from a single regexp is everything within the first < and
>the last > (rather than the next >) in the entire body of text, which is not
>helpful. 

I assume that you've used:

/<(.*)>/

the correct Perl 4 way is:

/<([^>]*)>/

but one of the may Perl 5 improvements are non-greedy matches:

/<(.*?)>/

Matthias

-----
Matthias Neeracher <neeri@iis.ee.ethz.ch> http://err.ethz.ch/members/neeri.html
           Haeresis est maxima opera maleficarum non creders