I need to parse a string that has multiple occurrences of a pattern that
is determined by an embeded count. For example:
02 s1n1 s1n2 3 s2n1 s2n2 s2n3 1 s3n1 4 s4n1 s4n2 s4n3 s4n4
02 is the count and I need to extract s1n1 and s2n2
3 is the count and I need to extract s2n1, s2n2 and s2n3
And so on.
So I tried to do:
$var =
/(.*?)\s+((?:.*?\s+){\1})(.*?)\s+((?:.*?\s+){\3})(.*?)\s+((?:.*?\s+){\5}
)/;
And was expecting "02" "s1n1 s1n2 " "3" "s2n1 s2n2 s2n3 " "1" "s3n1 "
"4" "s4n1 s4n2 s4n3 s4n4 " as matches.
This does not work.
The \1, \2 etc are not evaluated as 'iterators'. I tried the
experimental ?{} too.
---Closing information gaps-----
Ranga Nathan, Reliance Technology
>>SEVIS solution now! http://goreliance.com
>>Live demo at http://any2xml.com/docs/timesheet_demo.shtml<<
>>Get free COBOLExplorer at http://goreliance.com/download-products <<
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm