[IWE] Gruesome Perl Regular Expression Problem
Peter Whysall
iwe@warhead.org.uk
Thu, 1 Dec 2005 09:32:40 -0000
Here's a record from my data that I want to process:
! Site
A1M/9545A,3,S060,L,N,N,N,N, \
0, ! Additional Sites \
1, ! Adjacent Sites \
M1/5191A,OAJ, \
2, ! Downstream Sites \
A1M/9553A,NDV,0, \
M1/5200A,ODV,0, \
N, ! Partial Closures Prohibited \
1, ! Upstream Sites \
A1M/9537A,8,1,3,1,1,ORD,2,2,ORD,3,3,ORD \
As you can see, it's a rather obscure counted format.
I need to produce a report of which of these records has the partial
closures prohibited flag set to Y.
I'm cool with multiline and extended regexes, and I've got the matching for
the individual bits down pat.
What I'm struggling to find in the documentation is how to extract the
number of sites then match that number of sites before matching the next bit
of the record.
How do I match the digit then use the value of the digit to match a number
of things?
Cheers
Peter.
--
Peter Whysall
Site Data & Test Engineer, Serco Integrated Transport
email: peter.whysall@serco.com
voice: 01642 636943 fax: 01642 636701 ext: 6943
Serco Integrated Transport, Web Site: www.serco.com/sit -
This message, including attachments, is intended only for the use by the
person(s) to whom it is addressed. It may contain information which is
privileged and confidential. Copying or use by anybody else is not
authorised. If you are not the intended recipient, please contact the sender
as soon as possible. The views expressed in this communication may not
necessarily be the views held by Serco Integrated Transport.