Welcome to WebmasterWorld Guest from 54.166.224.46

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

preg replace help

     
2:08 pm on Jul 23, 2009 (gmt 0)

5+ Year Member



I want to strip out the following in a string:

[blah.com...]

Basically the URL followed by 4 0-9A-Za-z

I have this:

preg_replace('/http:\/\/blah\.com\/[0-9A-Za-z]{4}/', '', $text);

But it doesn't quite work. I still want it to show URL's like [blah.com...] and [blah.com...]

Any ideas?

2:29 pm on Jul 23, 2009 (gmt 0)

5+ Year Member



I actually want to extract the 'aBc4' first, store it in a variable, and then remove it from the string
3:09 am on Jul 24, 2009 (gmt 0)

10+ Year Member



idea:
if (preg_match('/(http:\/\/[^\/]+)\/([0-9A-Za-z]{4})/', $text, $match)) 
{
$url = $match[1];
$extract = $match[2];
}
else
{
$url = $text;
}
 

Featured Threads

Hot Threads This Week

Hot Threads This Month