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".
In reply to Re: Probably silly regex question / not so silly regex question
by tye
in thread Probably silly regex question / not so silly regex question
by theorbtwo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |