get_tag_regex( string $tag )
Return RegEx body to liberally match an opening HTML tag.
Description Description
Matches an opening HTML tag that:
- Is self-closing or
- Has no body but has a closing tag of the same name or
- Contains a body and a closing tag of the same name
Note: this RegEx does not balance inner tags and does not attempt to produce valid HTML
Parameters Parameters
- $tag
-
(string) (Required) An HTML tag name. Example: 'video'.
Return Return
(string) Tag RegEx.
Source Source
File: wp-includes/functions.php
function get_tag_regex( $tag ) {
if ( empty( $tag ) ) {
return;
}
return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |