How to remove a tag in php regular expression

藏色散人
Release: 2023-03-08 19:46:01
Original
2585 people have browsed it

php regular method to remove a tag: first create a PHP sample file; then use the regular expression "preg_replace('/([\s\S]*?<\ a="" >)/','',$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

I use /\< a href=\>[\s\S]{0,}\<\/a\>/, this can only match from the beginning of

Cannot match all a tags individually...

Implementation method:

Regular expression such as:

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

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template