in reply to search for exact string
Hi try this,
use strict; my $toFind="String"; while(<DATA>){ my $line=$_; chomp($line); if($line=~m/\b$toFind(?=[^\w\.]+|$)/i){ print "$line\n"; } }
__DATA__ blah blah string blah important stringstuff we wish to keep Unimportant string more stuff we wish to String.o Some more unimportant String.c
Punitha
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: search for exact string
by oko1 (Deacon) on Mar 27, 2008 at 14:08 UTC | |
Re^2: search for exact string
by Anonymous Monk on Apr 24, 2019 at 11:08 UTC | |
by roboticus (Chancellor) on Apr 24, 2019 at 12:42 UTC |
In Section
Seekers of Perl Wisdom