good catch, i guess i love php so much i just expect it to know what i
want it to do!

-js


John W. Holmes wrote:
> substr(basename($url), 0, strrpos($url,'.')-1);
> 
> note the '.' 
> 
> :)
> 
> ---John Holmes...
> 
> 
>>-----Original Message-----
>>From: Jonathan Sharp [mailto:js-lists@;sharpmedia.net]
>>Sent: Wednesday, November 13, 2002 10:50 PM
>>To: [EMAIL PROTECTED]
>>Cc: 'Charles Wiltgen'; 'List ? PHP General'
>>Subject: Re: [PHP] Trivial newbie regex question
>>
>>but my way is so pretty! i mean, who cares if it doesn't work
> 
> 'exactly'
> 
>>as you want, we're going for the ballpark solution right???
>>
>>fine...
>>substr(basename($url), 0, strrpos($url)-1);
>>
>>(note the strRpos)
>>
>>-js
>>
>>
>>John W. Holmes wrote:
>>
>>>He wants just "index" though, instead of "index.html"
>>>
>>>You can do it a variety of ways. You can use basename() like
>>
> Jonathan
> 
>>>said, and just strip off the last 5 characters using substr().
>>>
>>>Or you can use either of the following two regular expressions.
>>>
>>>preg_match('~/([^/]*)\.html$~', $source, $dest);
>>>ereg('/([^/]*)\.html$',$source,$dest);
>>>
>>>---John Holmes...
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>From: Jonathan Sharp [mailto:js-lists@;sharpmedia.net]
>>>>Sent: Wednesday, November 13, 2002 10:34 PM
>>>>To: Charles Wiltgen
>>>>Cc: List  PHP General
>>>>Subject: Re: [PHP] Trivial newbie regex question
>>>>
>>>>try basename('http://www.domain.com/stuff/index.html');
>>>>
>>>>-js
>>>>
>>>>
>>>>Charles Wiltgen wrote:
>>>>
>>>>
>>>>>Hello,
>>>>>
>>>>>I just want to get the "index" part of
>>>>
> "http://www.domain.com/stuff/
> 
>>>>>index.html".
>>>>>
>>>>>I'm trying to figure out this regex stuff, but it hasn't yet
>>>>
>>>clicked.
>>>
>>>
>>>>>Here's my best guess:
>>>>>
>>>>>   ereg('?/(*)\.html$', $source, $dest);
>>>>>
>>>>>To me -- and please be gentle -- this means, "Starting with the
>>>>
>>>forward
>>>
>>>
>>>>>slash closest to the end of $source, capture whatever comes after
>>>>
> it
> 
>>>and
>>>
>>>
>>>>>before '.html', and put it in $dest."  Obviously not correct, but
>>>>
>>>I've
>>>
>>>
>>>>spent
>>>>
>>>>
>>>>>an embarrassing amount of time feel stupid.  Help?
>>>>>
>>>>>-- Charles Wiltgen
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>--
>>>>PHP General Mailing List (http://www.php.net/)
>>>>To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
> 
> 
> 
> 
> 
> 




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

Reply via email to