in reply to Re^2: regex needed
in thread regex needed
It may help to talk it through in words first. The pattern you're looking at is:
- Two dollar signs (metacharacters, will need escaping)
- An open parenthesis (also needs escaping)
- Some text up to a closed parenthesis (capture this in $1)
- A closed parenthesis (escaped)
- Anything else that exists beyond that (captured in $2)
Now just put those elements together in a regex:
if( $line =~ m[ \$\$ # two dollar signs \( # open paren ([^)]+) # capture until closed paren \) # close paren (.*) # capture the rest, if any ]x ){ # do stuff with $1 and $2 }
Aaron B.
Available for small or large Perl jobs; see my home node.
|
---|
In Section
Seekers of Perl Wisdom