Perl Monk, Perl Meditation | |
PerlMonks |
Re: Pattern matchingby Athanasius (Archbishop) |
on Nov 10, 2018 at 08:54 UTC ( [id://1225520]=note: print w/replies, xml ) | Need Help?? |
Hello nursyza, and welcome to the Monastery! Parentheses within a regex are for capturing a match. To match a literal left parenthesis, you have to escape it:
Output:
Note: The /x modifier is used here to make the regex more readable. The regex says: match the beginning of a line (^), then capture as many characters as possible, providing that these captured characters are followed by (a) one or more spaces, then (b) an opening (left) parenthesis. Update: My use of \s+ above is sub-optimal, because it matches only the last whitespace character following the module name. Better would be:
which explicitly removes trailing whitespace from the module name. Hope that helps,
In Section
Seekers of Perl Wisdom
|
|