2016-04-21 74 views
-1

PHP正則表達式查找字符串我想找到PHP的正則表達式查找單詞串

stackoverflow.site在我的字符串

'stackoverflow.site' 特異性網址。後,我會用我自己的網址

$string='Regular expressions are a powerful tool for examining http://www.stackoverflow.site/uploads/2008/07/22/feldbalz-by-gus-wustemann-17.jpg and modifying text. Regular expressions themselves, with a general pattern notation almost like a mini programming language, allow you to describe and parse text. They enable you to search for patterns within a string, extracting matches http://www.stackoverflow.site/uploads/2008/07/22/feldbalz-by-gus-wustemann-squ1.jpg flexibly and precisely. However, you should note that because regular expressions are more powerful, they are also slower than the more basic string functions. You should only use regular expressions if you have http://www.stackoverflow.site/uploads/2008/07/22/feldbalz-by-gus-wustemann-12.jpg a particular need. 
This tutorial gives a brief overview of http://www.stackoverflow.site/uploads/2008/07/22/feldbalz-by-gus-wustemann-2.jpg basic regular expression syntax and then considers the functions that PHP provides for working with regular expressions.'; 

$find='[http://www.stackoverflow.site/uploads/]'; 
+0

正則表達式不是其他 –

+4

這個看起來有點黑幕......說最少:)) –

回答

0

使用preg_quote更換隻爲stackoverflow.site自動特殊字符轉義在正則表達式

$find='http://www.stackoverflow.site/uploads/'; 
$rfind=preg_quote($find); 
preg_replace($rfind, "mysite", $input_lines); 
+1

再次;爲什麼使用正則表達式時,你只是在做文字串替換?如果你真的想破壞性能,我建議使用一個在線web服務來做1998年在計算機上運行的正則表達式替換。也許在那裏添加一些'sleep()'。 – h2ooooooo