in reply to regex assistance for parsing arg list
Updated:Removed some of the ugliness from the formatting in code.use strict; use warnings; while ( <DATA> ) { my $string = $_; if ( $string =~ /func[A-Za-z]\( (func[A-Za-z]\([^\)]+\)|[^,]+) #looks for a function a +nd if not found then ,(func[A-Za-z]\([^\)]+\)|[^,]+) #grab everything to the +comma ,(func[A-Za-z]\([^\)]+\)|[^,]+) ,(func[A-Za-z]\([^\)]+\)|[^,]+)\)/x) { print "FOR STRING: $string", '$1 = ',$1,$/, '$2 = ',$2,$/, '$3 = ',$3,$/, '$4 = ',$4,$/,$/; } } __DATA__ funca(1,2,3,4) funca(funcH(A,B,C),2,3,4) funca(1,funcH(A,B,C),3,4) funca(1,2,funcH(A,B,C),4) funca(1,2,3,funcH(A,B,C))
-enlil
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: regex assistance for parsing arg list
by ihb (Deacon) on Feb 04, 2003 at 19:45 UTC |