Regular Expressions help

Joel Pearson pearj at iprimus.com.au
Mon Dec 9 22:44:06 EST 2002


I should have included some more of the data to put it in context:

<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
&nbsp

All that data is on a single line, so I never have a short string

~~~~~~~~~~~~~~~~~~~~~~~
Joel Pearson
Email: pearj at writeme.com
ICQ:1580379
MSN: joelpearson at hotmail.com


-----Original Message-----
From: Alex Satrapa [mailto:grail at goldweb.com.au] 
Sent: Monday, 9 December 2002 10:21 PM
To: pearj at writeme.com
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.

HTH







More information about the linux mailing list