Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.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
Regex 用于替换html标记中特定标记的正则表达式_Regex - Fatal编程技术网

Regex 用于替换html标记中特定标记的正则表达式

Regex 用于替换html标记中特定标记的正则表达式,regex,Regex,在我的一个应用程序中,我需要去掉或删除所有html标记中的特定标记,如: Input: `<div<del>class</del>=<del>"example"</del>>` Output: `<div class="example">` 但是它正在替换所有的标记,我只想替换html标记中的标记。我不想删除所有的标记。我只想删除那些出现在html标记中的标记。使用strip\u标记 strip_tags($text,

在我的一个应用程序中,我需要去掉或删除所有html标记中的特定标记,如:

 Input: `<div<del>class</del>=<del>"example"</del>>`
 Output: `<div class="example">`
但是它正在替换所有的标记,我只想替换html标记中的标记。我不想删除所有的
标记。我只想删除那些出现在html标记中的
标记。

使用strip\u标记

strip_tags($text, '<del>');
strip_标签($text,”);
使用str\u替换

str_replace($input,"<del>");
stru替换($input,”);
使用:

preg_replace(“//”,“”,preg_replace(“/”,“”,$string););

您之前的问题发生了什么:以及?正如我在问题中指定的,我不想删除所有
标记;我只想在html标记中包含yts的地方删除它。。。
str_replace($input,"<del>");
preg_replace("/<tag>/", "", preg_replace("/<\/tag>/", "", $string););