in reply to Probably silly regex question / not so silly regex question
Well, not all file names have extensions, so you might want one of these:
( $base, $ext )= $file =~ /^(.*?)([.][^.]*)?$/s; $ext= ( $base= $file ) =~ s/([.][^.]*)$// ? $1 : ""; $base= substr( $ext= $file, 0, 0xffff & rindex($file,"."), "" );
/.*?c/s and /[^c]*c/ will always (I'm pretty sure) match the same thing (note the addition of "s" to the first one) as they stand. But you were using these as part of a larger regex, and there they don't always match the same thing. For example, /.*?cd/s and /[^c]*cd/ (adding a "d" to each one) don't always match the same things. On the string "abcabcd", the first will match "abcabcd" while the second will only match "abcd".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SOLUTION : Not so silly regex question
by Anonymous Monk on Aug 02, 2000 at 01:29 UTC |