in reply to Yet another regex question
I was hoping there might be some trick like
$programSource =~ s/in \(('([^']*)'[,])*\)/=~ m#[$2$3$4$5$6$7$8$9]#;/g;
where perhaps the outer group of parentheses would be $1 and any number of nested inner parentheses groups would be matched for all patterns matching ([^']*) inside the single-quotes. In a more broken-out fashion:
$programSource =~ s/in \( (' <-- outer group start goes in $1 ([^']*) <-- inner group chars between '' '[,])* <-- followed by optional comma, close outer group + and repeat outer group for any number of repetitions \)/=~ m#[$2$3$4$5$6$7$8$9]#;/g; <-- put inner grou +ps in match (up to 8 of them, anyway)
Thanks for your thoughts.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Yet another regex question
by QM (Parson) on Aug 26, 2005 at 22:07 UTC |