eversuhoshin has asked for the wisdom of the Perl Monks concerning the following question:
Hello dear monks~
Could someone help me write a code that shows what part of the regular expression the text matched?
I have to match on bunch of words (about 15) to find the SEC filing that I want for instance "director" and "resignation."
Since I am still learning perl I was thinking of just creating separate variables indicating matched words
if $text=~m/\bdirector\b/ $director=1; if $text=~m/\bresignation\b/ $resign=1;
Is there a way I can do it more elegantly using
if $text=~m/\b(director|resignation)\b/ # code that shows which word matched;
Thank you again :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What is being matched?
by graff (Chancellor) on Apr 02, 2011 at 04:47 UTC | |
by eversuhoshin (Sexton) on Apr 02, 2011 at 15:54 UTC | |
|
Re: What is being matched?
by ww (Archbishop) on Apr 02, 2011 at 02:59 UTC | |
|
Re: What is being matched?
by AnomalousMonk (Archbishop) on Apr 02, 2011 at 09:23 UTC | |
|
Re: What is being matched?
by bart (Canon) on Apr 02, 2011 at 10:17 UTC | |
|
Re: What is being matched?
by Marshall (Canon) on Apr 02, 2011 at 17:32 UTC |