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

[MacPerl] Searching for delimiters using regular expressions




Hello,

I'm wondering if there's a standard way in Perl to search for text set off
by delimiters.

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. 

Of course, there are ways to do it that take several steps (search for the
<, calculate the length of the string leading up to the <, then search the
remainder for >, calculate that length, and then take the substring).
However, this seems to be such a common operation that Perl would have some
shortcut for extracting data set off by delimiters in a single step.

Thanks for your help,


Jonah
--
Jonah Benton
Arcus Incorporated
http://www.arcus.net/