PDA

View Full Version : Simple regex


Dave#
07-29-2003, 11:32 AM
$newstext = strip_tags($newstext,"");
//$newstext = wordwrap( $newstext, 20 );
$newstext = preg_replace("/[a-zA-Z0-9]{12,}/s", " ", $newstext);
$newstext = ereg_replace("^http", "", $newstext);
$newstext = ereg_replace("http://", "", $newstext);
$newstext = preg_replace("/\[.*?\]/si","", $newstext);
//$newstext = preg_replace("/\[URL=.*\](.*)\[/url\]/Ui", "\\1", $newstext);
$newstext = preg_replace("/\[URL=.*\]/Ui", "", $newstext);
$newstext = ereg_replace("{bbusername}", "", $newstext);


I'm trying unsuccessfully to strip all vbcode and any urls from $newstext but failing miserably - how can I get rid of any string that contains http ?

Kriek
07-31-2003, 02:55 AM
The following regular expression should remove all URL's in a string ;)
$newstext = eregi_replace("(http|https|ftp)://([[:alnum:]/\n+-=%&:_.~?]+[#[:alnum:]+]*)", " ", $newstext);