in reply to Parsing Strings
Hello doofus,
To capture the literal parentheses, put them inside the capturing parentheses. But you want the outermost parentheses, so change to a greedy quantifier. And if you know that your input string is such that the text captured in $pin will always precede the text captured in $sig, you can combine the two regular expressions into one:
if ($sp =~ m{ \. ( [^(]* ) ( \( .* \) ) }x) { print "pin = $1\n"; print "sig = $2\n"; }
But note that this does not guarantee that the outer parentheses are matched. For that, you will need to use the techniques described in perlfaq6, “Can I use Perl regular expressions to match balanced text?”
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|