Regular Expressions help

Kim Holburn kim.holburn at
Tue Dec 10 10:21:13 EST 2002

At 11:24 PM +1100 2002/12/09, Joel Pearson wrote:
>Hmm that still doesn't seem to work, I'm doing it in php if that makes
>any difference, but the function I'm using claims to be perl compatible


$data='<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';

while ($data =~ s/<option value=([A-Z]{3,4})> (\([^<]+\)) \1( \&nbsp)+<\/option>//) {
  print "1=\"$1\" 2=\"$2\" 3=\"$3\" \n";

> perl  Desktop/testperl
1="IMD" 2="(IMDEX LIMITED)" 3=" &nbsp"
1="IMF" 2="(IMF (AUSTRALIA) LTD)" 3=" &nbsp"
1="IMH" 2="(IMT HOLDINGS LIMITED)" 3=" &nbsp"
1="IMI" 2="(INTEGRA MEDICAL)" 3=" &nbsp"
1="IMIO" 2="(INTEGRA MEDICAL)" 3=" &nbsp"
1="IMP" 2="(IMPERIAL ONE LIMITED)" 3=" &nbsp"
1="IMU" 2="(IMUGENE LIMITED)" 3=" &nbsp"
1="IMW" 2="(INSURANCE MY WAY)" 3=" &nbsp"

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