more useful options | |
PerlMonks |
Re^3: matching the wordsby Kenosis (Priest) |
on Feb 16, 2013 at 21:10 UTC ( [id://1019076]=note: print w/replies, xml ) | Need Help?? |
Yes, that helped! Here's one option that substitutes the "_" with ".+" for use in a regex (use "." if you want only one letter to match):
Output:
Only whole words are matched, as word boundires (\b) are used in the regex which, if omitted, will also match substrings within the dictionary words. Hope this helps! Update: Below is an updated version which adapts BrowserUk's preferred solution:
Output:
If you want the "_" to be matched by more than one letter in the dictionary words, change the substitution to $re =~ s/_/\\S+/;.
In Section
Seekers of Perl Wisdom
|
|