in reply to substring extraction

pretty easy with a regex....
my $string = 'cesi'; while($istr =~ /(\S*$string\S*)/gi) { print "$1\n"; }
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).

If you want to know the location of the word in the source string the special array @- and @+ should come in handy.

                - Ant
                - Some of my best work - (1 2 3)

Replies are listed 'Best First'.
Re^2: substring extraction
by bfdi533 (Friar) on Jan 05, 2006 at 15:54 UTC

    Perfect; that was the missing piece. I knew that most likely had to use a regex but that is admittedly a weak point for me. This does just what I am looking for.

    Thanks for the help and the rapid reply.