homepage Welcome to WebmasterWorld Guest from 50.17.21.7
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
preg replace help
FiRe




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

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




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

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

NomikOS




msg:3958567
 3:09 am on Jul 24, 2009 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved