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. *?>
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:
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('/(<a.*?>[\s\S]*?<\/a>)/','',$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!