Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
So in the above example I would only want to match the last line. The words (train times in my example) are not guaranteed to be at the beginning of a line, however the to/from if they appear in the text would always follow these two words. I tried doing thistrain times to xyz train times from xyz train times including xyz
This however still seems to match every line. How do ignore lines that have \w+\s\w+\s to|from in them ?if $line =~ /train times ([^to ]|[^from ])+/ { do something with line }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: negate pattern match
by GrandFather (Saint) on Jan 31, 2006 at 09:50 UTC | |
by Anonymous Monk on Jan 31, 2006 at 14:14 UTC | |
by GrandFather (Saint) on Jan 31, 2006 at 18:39 UTC | |
by Anonymous Monk on Feb 02, 2006 at 10:56 UTC | |
by Anonymous Monk on Jan 31, 2006 at 10:00 UTC | |
|
Re: negate pattern match
by tirwhan (Abbot) on Jan 31, 2006 at 09:56 UTC | |
by GrandFather (Saint) on Jan 31, 2006 at 10:15 UTC | |
|
Re: negate pattern match
by olus (Curate) on Jan 31, 2006 at 18:13 UTC |