Link to home
Start Free TrialLog in
Avatar of sushestvo
sushestvo

asked on

replacement within a string

I have a string that could be up to 8000 characters.
String is a text with pictures and stuff like that.
How can I do a replace on the string to cut out everything that is an email, I mean that looks like this:
http://someurl/folder/anotherfolder/whatever/name.jpg
or
http://someurl/folder/anotherfolder/whatever/name.gif

Pretty much I want to remove all the pics from the $string.
I guess it would be preg_replace with regexp?
But I have no clue how to do this. Please someone help.
Avatar of Roonaan
Roonaan
Flag of Netherlands image

$preg = '#http://[\w/\.]+#i';
$replace = '';
$string = preg_replace($preg, $replace, $string);

-r-
Avatar of sushestvo
sushestvo

ASKER

it doesn't really work... especially with multiple pics on in the $string
or even with this (http://images.ciao.com/ide/images/products/normal/784/product-102784.jpg)
it leaves "-102784.jpg" behind.
Is it possible to cut out everything between http and jpg ?
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial