PHP正则表达式在我要查找的字符串中找到特定URL
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/]';
使用preg_quote
自动逃脱正则表达式中的特殊字符
$find='http://www.stackoverflow.site/uploads/';
$rfind=preg_quote($find);
preg_replace($rfind, "mysite", $input_lines);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句