我有一個非常簡單的問題,那就是......給我一個hedache ...修剪/擦除/移除鏈接與正則表達式
我只想修剪所有鏈接(www.link.com) (http://www.link.com)(http://link.com)... wathever,從給定的字符串與此正則表達式:
$regex = "(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?";
只要打開他們的空白。
這是我認爲不會工作實際代碼...
<?php
$string = 'ads dsa asd asd as da ds www.something.com adss dsad a sdas d';
$pattern = "(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&/~\+#]*[\w\-\@?^=%&/~\+#])?";
$replacement = ' nothing ';
echo preg_replace($pattern, $replacement, $string);
?>
它一直在說我,
(!) Warning: preg_replace() [function.preg-replace]: Unknown modifier ':' in C:\wamp\www\ceva.php on line 9
Call Stack
# Time Memory Function Location
1 0.0005 363504 {main}() ..\ceva.php:0
2 0.0005 363952 preg_replace () ..\ceva.php:9
任何幫助,將不勝感激:d
@StackOverlowNewbie:這也不算太壞。 – alex