Welcome to WebmasterWorld Guest from 107.20.5.156

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

preg replace help

     

FiRe

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

10+ 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?

FiRe

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

10+ Year Member



I actually want to extract the 'aBc4' first, store it in a variable, and then remove it from the string

NomikOS

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;
}