|
|
| P is for Practical | |
| PerlMonks |
Re: How do I extract the data that comes after a certain word?by ikegami (Pope) |
| on Jun 18, 2012 at 19:55 UTC ( #976886=note: print w/ replies, xml ) | Need Help?? |
|
First, previous answers use `$1`, but I hate using global variables when it's not necessary. It's not necessary here. Second, previous answers assume you don't want to capture newlines, but you didn't say anything of the kind. Fix:
Finally, using the `?` greediness modifier can lead to surprises (especially if you use more than one in a single pattern). If given
the above regex will capture
If you want
use the following instead:
(?:(?!STRING).) is to STRING as [^CHAR] is to CHAR.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||