Hi everyone
I was wondering if there is an easy way to search a string for matching parentheses, using the m// and s/// methods.
What I mean is the following. Say we have the string that looks like this:
Parameter1(info, blah), Parameter2(new info(DN), blah)...
I want to be able to extract each parameter and its information within the parentheses. So I want my search procedure to ignore the parentheses "(DN)" in teh second parameter. So I want to be able to extract:
"Parameter1(info, blah)", and
"Parameter2(new info(DN), blah)"
as two new strings.
I can probably sit down and write a page long program to do it... but I'm wondering if there is a short-cut available. Some kind of notation within the // that tells it to "find next parentheses, and ITS matching end-parentheses"...
Let me know if you have any ideas!
Thanks!
Emma
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.