Syntactic Confectionery Delight | |
PerlMonks |
RegEx for Matching paranthesisby Anonymous Monk |
on Feb 17, 2004 at 14:25 UTC ( [id://329597]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I need to extract a text in between nested paranthesis, and I would like to have the text in between the outermost one. For eg., if the text is given as
<code start>I am (giving this (text to (tell you) that this) will give) you the result.<code end>
In this case, I need the phrase,
(giving this (text to (tell you) that this) will give)
This should hold for any number of nested paranthesis. Is there a way to achieve this using Regular Expressions? Or is it the conventional way that is best suited for this? Is there a function which can give the matching paranthesis locations in a given string?
As I am a beginner to Regular Expressions of Perl, a code snippet would be of immense help to me.
Back to
Seekers of Perl Wisdom
|
|