Hi,
Is it possible to use Perl to match any number of parentheses using a regex?
For example, if I have an entry like the following:
A = ( abc ( b = def ( c = efg ) ) )
B = (abc)
C = (
(a = abc)
(f = ghi)
)
..etc. (basically each entry can be split over multiple lines, and have an
arbitrary number of parameters enclosed within parentheses). I would like to
be able to match the beginning of each entry, e.g. parsing the above file
results in
A
B
C
But I'm not sure how to manage the arbitrary number of ( and ) for each
entry. If I was doing this in C, I could use a pushdown stack to to track
the number of parentheses. Is there an elegant way to do this in Perl? (I've
found more elegant ways to do things in Perl than I ever thought possible
with a single language, but this one has eluded me so far.. :-))
Cheers!
Rory
--------------------------------------------
Rory Winston,
Developer,
OneLine Team,
TeleWest Communications,
Genesis Business Park,
Albert Drive,
Woking Surrey,
GU21 5RW
mailto: rory.winston at telewest.co.uk
phone: 01483 295 653
------------------------------------------------------------------------------
Live Life in Broadband
www.telewest.co.uk
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material.
Statements and opinions expressed in this e-mail may not represent those of the company. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender immediately and delete the material from any computer.
==============================================================================
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!