2016-04-21 73 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