Regular Expressions help

Kim Holburn kim.holburn at
Mon Dec 9 23:01:50 EST 2002

What is the program doing the grep anyway?

At 10:44 PM +1100 2002/12/09, Joel Pearson wrote:
>I should have included some more of the data to put it in context:

/value=([A-Z]{3,4})> \(([^<]+)\) \1\( \&nbsp\)+<\/option/

><option value=IMD> (IMDEX LIMITED) IMD &nbsp &nbsp &nbsp &nbsp &nbsp
>&nbsp &nbsp &nbsp</option><option value=IMF> (IMF (AUSTRALIA) LTD) IMF
>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp</option><option
>value=IMH> (IMT HOLDINGS LIMITED) IMH &nbsp &nbsp &nbsp &nbsp &nbsp
>&nbsp &nbsp &nbsp</option><option value=IMI> (INTEGRA MEDICAL) IMI &nbsp
>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp</option><option value=IMIO>
>(INTEGRA MEDICAL) IMIO &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
>&nbsp</option><option value=IMP> (IMPERIAL ONE LIMITED) IMP &nbsp &nbsp
>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp</option><option value=IMPOB>
>(IMPERIAL ONE LIMITED) IMPOB &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
>&nbsp</option><option value=IMPOC> (IMPERIAL ONE LIMITED) IMPOC &nbsp
>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp</option><option value=IMU>
>(IMUGENE LIMITED) IMU &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
>&nbsp</option><option value=IMW> (INSURANCE MY WAY) IMW &nbsp &nbsp
>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp</option><option value=INF>
>(INFOSENTIALS LIMITED) INF &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
>All that data is on a single line, so I never have a short string
>Joel Pearson
>Email: pearj at
>MSN: joelpearson at
>-----Original Message-----
>From: Alex Satrapa [mailto:grail at]
>Sent: Monday, 9 December 2002 10:21 PM
>To: pearj at
>Cc: Linux user group
>Subject: Re: Regular Expressions help
>Joel Pearson wrote:
>> Just say I have this data "<option value=IMD> (IMDEX LIMITED) IMD",
>> normally what happen is it pulls out IMB and IMDEX LIMITED.
>What's the thing after the brackets? If it's always a short string, and
>never has brackets, you might want to try:
>"/value=(.{3})> \((.+)\)[^)]+$/"
>That is, match everything from the first bracket after the
>angle-bracket, to the last bracket before the end of the line.

Kim Holburn 
Network Consultant - Telecommunications Engineering
Research School of Information Sciences and Engineering
Australian National University - Ph: +61 2 61258620 M: +61 0417820641
Email: kim.holburn at  - PGP Public Key on request

Life is complex - It has real and imaginary parts.
     Andrea Leistra (rec.arts.sf.written.Robert-jordan)

More information about the linux mailing list