Home  >  Article  >  Backend Development  >  How to write the regular expression of H tag

How to write the regular expression of H tag

WBOY
WBOYOriginal
2016-09-19 09:16:401584browse

<code>protected $bbcode_table = array();</code>

代码

<code>private function _code_callback($match)
{
    return "<pre class="brush:php;toolbar:false">" . str_replace('[', '<span>[</span>', $match[1]) . "
"; }

加粗

<code>private function _b_callback($match)
{
    return "<strong>$match[1]</strong>";
}
</code>

这个是代码的正则表达式
// Replace [code]...[/code] with

<code>...</code>

$this->bbcode_table"/[code\[/code]/is"] = '_code_callback';
这个是加粗的正则表达式
// Replace [b]...[/b] with ...
$this->bbcode_table"/[b\[/b]/is"] = '_b_callback';

那么H标签的正则表达式要怎么写呢?
就是H1,H2,H3,H4,H5,H6的标签

回复内容:

<code>protected $bbcode_table = array();</code>

代码

<code>private function _code_callback($match)
{
    return "<pre class="brush:php;toolbar:false">" . str_replace('[', '<span>[</span>', $match[1]) . "
"; }

加粗

<code>private function _b_callback($match)
{
    return "<strong>$match[1]</strong>";
}
</code>

这个是代码的正则表达式
// Replace [code]...[/code] with

<code>...</code>

$this->bbcode_table"/[code\[/code]/is"] = '_code_callback';
这个是加粗的正则表达式
// Replace [b]...[/b] with ...
$this->bbcode_table"/[b\[/b]/is"] = '_b_callback';

那么H标签的正则表达式要怎么写呢?
就是H1,H2,H3,H4,H5,H6的标签

<code><(h[1-6])>([\S\s]*?)<\/\1></code>

How to write the regular expression of H tag

Statement:
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