in reply to substring extraction
not tested, but should work... the i does case insensitive matching, the g matches more than once, allowing the loop to catch all occurances. Lowercasing the string ahead of time may help the speed, especially if you want the output to be lowercase (though you probably don't if you have things like URLs).my $string = 'cesi'; while($istr =~ /(\S*$string\S*)/gi) { print "$1\n"; }
If you want to know the location of the word in the source string the special array @- and @+ should come in handy.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substring extraction
by bfdi533 (Friar) on Jan 05, 2006 at 15:54 UTC |