[\s\S]*?<\/a>)/',' ',$str);" Just remove the a tag."/> [\s\S]*?<\/a>)/',' ',$str);" Just remove the a tag.">

Home >Backend Development >PHP Problem >How to remove a tag in php regular expression

How to remove a tag in php regular expression

藏色散人
藏色散人Original
2021-03-18 09:35:472618browse

php regular method to remove a tag: first create a PHP sample file; then use the regular expression "preg_replace('/([\s\S]*?f371a58f3ef87676efa317bc10930c69)/','',$str);" Just remove the a tag. *?>

How to remove a tag in php regular expression

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php regular match all a tag, and delete the

Specific question:

The basic format is fa3fcf4408e3a2da0542159d10a6fbc1

I use /\c5de07a428a9dc07a88dc24f74619d71[\s\S]{0,}\ffdd5a1c987b4d0babd4a5f667981057/, this can only match from the beginning of f069800de5bef5f3867e98da1000a95c

Cannot match all a tags individually...

Implementation method:

Regular expression such as:

preg_replace(&#39;/(<a.*?>[\s\S]*?<\/a>)/&#39;,&#39;&#39;,$str);

Recommended learning: "PHP video tutorial

The above is the detailed content of How to remove a tag in php regular expression. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn