Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.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
适用于<;a id=";一些“随机文本”/&燃气轮机;在php中_Php_Html_Regex - Fatal编程技术网

适用于<;a id=";一些“随机文本”/&燃气轮机;在php中

适用于<;a id=";一些“随机文本”/&燃气轮机;在php中,php,html,regex,Php,Html,Regex,我想换一个 带有空格或”。我正在使用 $a=preg_replace("/<\\/?a\\s|id(\\s+.*?>|>)/", "",$file); $a=preg_replace(“/”)/“,”,$file); 但它只删除我建议使用以下正则表达式: /(<a\s+id="[^"]*"\s*\/>)/ 当然是。正则表达式不是火箭科学。我建议您使用一些在线regex测试工具进行开发,它们非常有帮助:-) $a = preg_replace('/(<a\

我想换一个
带有
空格
。我正在使用

$a=preg_replace("/<\\/?a\\s|id(\\s+.*?>|>)/", "",$file);
$a=preg_replace(“/”)/“,”,$file);

但它只删除
我建议使用以下正则表达式:

/(<a\s+id="[^"]*"\s*\/>)/

当然是。正则表达式不是火箭科学。我建议您使用一些在线regex测试工具进行开发,它们非常有帮助:-)
$a = preg_replace('/(<a\\s+id="[^"]*"\\s*\\/>)/', '',$file);
<?php
$subject = 'test-<a id="any_text"/>-test';
$pattern = '/(<a\\s+id="[^"]*"\\s*\\/>)/';
print_r(preg_replace($pattern, '', $subject));
test--test