Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hope this should have been asked before, but I am not able to search what I was looking for. Here I am reading from a data file line by line and process each line.
my $Line = "1243 That will efficiently match a nonempty group with mat +ching parentheses two levels deep or less."; if( $Line =~ /^(\d{4}) ([^\.]+?[\.\!\?])$/ ) { print "$1\n$2\n"; #Do something } elseif( #do some other check }
In the above example I would like to skip the line if it contains a word “group”. This word can occur anywhere in that line. How do I achieve in a single regex? Currently I save $2 in a variable and check for word “group”. This makes my life difficult as I have to continue the elsif loot if “group” present. Appreciate your help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Excluding Words in RegEx
by ikegami (Patriarch) on Nov 06, 2011 at 05:03 UTC | |
by ramprasad27 (Sexton) on Nov 06, 2011 at 07:02 UTC | |
by Lotus1 (Vicar) on Nov 06, 2011 at 16:04 UTC | |
by ikegami (Patriarch) on Nov 07, 2011 at 04:35 UTC | |
|
Re: Excluding Words in RegEx
by CountZero (Bishop) on Nov 06, 2011 at 08:15 UTC | |
by Marshall (Canon) on Nov 06, 2011 at 11:28 UTC | |
by CountZero (Bishop) on Nov 06, 2011 at 16:31 UTC | |
by Lotus1 (Vicar) on Nov 06, 2011 at 16:11 UTC | |
by CountZero (Bishop) on Nov 06, 2011 at 16:29 UTC | |
by dominic01 (Sexton) on Nov 07, 2011 at 04:08 UTC |