Regular Expressions help

Joel Pearson pearj at iprimus.com.au
Mon Dec 9 23:24:36 EST 2002


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
(preg_match_all)

Thanks

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


-----Original Message-----
From: Kim Holburn [mailto:kim.holburn at anu.edu.au] 
Sent: Monday, 9 December 2002 11:10 PM
To: pearj at writeme.com; 'Alex Satrapa'
Cc: 'Linux user group'; Joel Pearson
Subject: RE: Regular Expressions help

At 11:01 PM +1100 2002/12/09, Kim Holburn wrote:
>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:

Oops, should be this but the bit you want is \2 instead of \1:

/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
>>&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
>
>
>--
>--
>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 anu.edu.au  - PGP Public Key on request
>
>Life is complex - It has real and imaginary parts.
>     Andrea Leistra (rec.arts.sf.written.Robert-jordan)


-- 
--
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 anu.edu.au  - 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