get_tag_regex() - WordPress 函数参考中文文档

返回介绍

get_tag_regex()

发布于 2017-09-11 字数1362 浏览 839 评论 0

get_tag_regex( string $tag )

Return RegEx body to liberally match an opening HTML tag.


描述

Matches an opening HTML tag that:

  1. Is self-closing or
  2. Has no body but has a closing tag of the same name or
  3. 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


参数

$tag

(string)
(Required)
An HTML tag name. Example: ‘video’.


返回值

(string) Tag RegEx.


源代码

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 ) );
}

更新日志

Version 描述
3.6.0 Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    tag_escape()

User Contributed Notes

上一篇:get_tag_link()

下一篇:get_tag_template()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!