我想删除第一个之前的所有文本,使用http或只是www,我希望URL也被删除。看这个例子。删除字符串之前的所有文本并包含url
$str = 'some text bla bla http://www.blabla.com this is another text';
$new_str = magic_function($str);
$new_str = 'this is another text';
有了这个的preg_replace我可以更换URL(一个是http和一个没有)
$string = preg_replace('|https?://www\.[a-z\.0-9/#]+|i', 'url_replace', $string);
$string = preg_replace('|www\.[a-z\.0-9]+|i', 'url_replace', $string);
所以,现在我换成url_replace的URL。现在我想删除所有文字,直到包括'url_replace'。
'。*'.......... – 2014-09-29 17:07:27