in reply to substring extraction
I have a hard time understanding your question. Why would you want to "extract" a known substring from another: you already have it! Maybe you meant "remove"? If that's the case, then the simplest thing IMO is to use a regular expression:
Alternatively, you can use substr, index, and length:$string =~ s/\Q$substring//;
my $offset = index( $string, $substring ); substr( $string, $offset, length $substring, '' ) if $offset > -1;
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substring extraction
by ishnid (Monk) on Jul 20, 2005 at 23:28 UTC |