in reply to Extract string from rear of string
update: Indeed, Aigherach is right about the the fact that rindex takes a substring, but that is not germane to the discussion. If you're trying to identify the extension, that probably means you're looking for the rightmost dot in a string.
substr( $s, 0, rindex( $s, '.' )); # the part before the dot substr( $s, rindex( $s, '.' ) + 1); # the part after the dot
But that has portability considerations, and as such is dealt with by fileparse from the File::Basename module.
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Extract string from rear of string
by Aighearach (Initiate) on Dec 28, 2001 at 02:46 UTC | |
|
Re: Re: Extract string from rear of string
by Anonymous Monk on Dec 28, 2001 at 06:34 UTC | |
by hacker (Priest) on Dec 28, 2001 at 15:20 UTC | |
by ichimunki (Priest) on Dec 28, 2001 at 22:49 UTC |