Returns RegEx body to liberally match an opening HTML tag.
Matches an opening HTML tag that:
Note: this RegEx does not balance inner tags and does not attempt to produce valid HTML
$tagstringrequired
'video'.function get_tag_regex( $tag ) {
if ( empty( $tag ) ) {
return '';
}
return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
}
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_tag_regex