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

How to write the regular expression of H tag

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-09-19 09:16:40
Original
1658 people have browsed it

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

代码

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

加粗

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

这个是代码的正则表达式
// 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>
Copy after login
Copy after login

代码

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

加粗

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

这个是代码的正则表达式
// 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>
Copy after login

How to write the regular expression of H tag

Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template