Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php:如何用正则表达式替换以下字符串?_Php_Regex - Fatal编程技术网

php:如何用正则表达式替换以下字符串?

php:如何用正则表达式替换以下字符串?,php,regex,Php,Regex,希望替换所有出现的,包括双引号 ”http://somebunchofchar“ 到 “链接” 我想出了preg\u replace(“/\”http:\/\/.\”/I“,“\”link\”,$string)只需在点后添加星号和问号即可 preg\u replace(“/\”http:\/\/.\”/i“,“\”link\”,$string)只需在点后添加星号和问号即可 preg\u replace(“/\”http:\/\/.\”/i“,“\”link\”,$string)看看这里: 如何将

希望替换所有出现的,包括双引号

”http://somebunchofchar“

“链接”


我想出了
preg\u replace(“/\”http:\/\/.\”/I“,“\”link\”,$string)

只需在点后添加星号和问号即可


preg\u replace(“/\”http:\/\/.\”/i“,“\”link\”,$string)

只需在点后添加星号和问号即可

preg\u replace(“/\”http:\/\/.\”/i“,“\”link\”,$string)

看看这里: 如何将URL与正确的模式匹配;然后使用preg_替换为特定的regexp模式;-)(您可以很容易地在模式的开头和结尾添加这些引号):-)

只需查看这里: 如何将URL与正确的模式匹配;然后使用preg_替换为特定的regexp模式;-)(您可以很容易地在模式的开头和结尾添加这些引号):-)

您可以使用:

preg_replace('~"http://[^"]*"~i', '"link"', $string);
您可以使用:

preg_replace('~"http://[^"]*"~i', '"link"', $string);