Does it HAVE to be done with a regexp?

<?
$file = "foo.bah.cat.dog.php";
$pre = count($segments = explode('.',$file)) - 2;
echo $segments[$pre];
?>

You'd have to do a test to see which is quicker (regexp or this method), but
I *think* this would be quicker.  Better still, it's "future proof" by
working for a.file.with.more.than.two.dots :)

Cheers,

Justin




on 12/12/02 4:40 AM, Luca ([EMAIL PROTECTED]) wrote:

> How to read "pre-extension" of file with regular expression?
> Example: name.preextension.doc
> 
> I need to read "preextension"
> 
> Tanks!
> 
> 

Justin French
--------------------
http://Indent.com.au
Web Development & 
Graphic Design
--------------------


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to