对preg_match有点帮助 [英] a little help with preg_match

查看:71
本文介绍了对preg_match有点帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好......我正在尝试写一个正则表达式来匹配html标签的内容




我需要匹配< h1i.e。
的内容
< h1> Hello World< / h1>

< h1 class =" red_background"> Hello World< / h1>

< h1>< img src =" red.gif" />< / h1>


等...


有人可以帮我吗?


谢谢!!

Hello... I''m trying to write a regular expression to match the content
of a html tag.

I need to match the content of <h1i.e.

<h1>Hello World</h1>
<h1 class="red_background">Hello World</h1>
<h1><img src="red.gif"/></h1>

etc...

can anyone help me?

Thanks!!

推荐答案

..oO(nintesa)
..oO(nintesa)

> Hello ...我正在尝试编写正则表达式来匹配内容
我需要匹配< h1i.e的内容。

< h1> Hello World< / h1>
< h1 class =" red_background"> Hello World< / h1>
< h1>< img src =" red.gif" />< / h1>

任何人都可以帮助我吗?
>Hello... I''m trying to write a regular expression to match the content
of a html tag.

I need to match the content of <h1i.e.

<h1>Hello World</h1>
<h1 class="red_background">Hello World</h1>
<h1><img src="red.gif"/></h1>

etc...

can anyone help me?



尝试这种模式:


#< h1 [^>] *>(。+?)< ; / h1>#


Micha

Try this pattern:

#<h1[^>]*>(.+?)</h1>#

Micha


Michael Fesser ha scritto:
Michael Fesser ha scritto:

.oO(nintesa)
.oO(nintesa)

>你好......我正在尝试写一个正则表达式来匹配内容
一个html标签。

我需要匹配< h1i.e的内容。

< h1> Hello World< / h1>
< h1 class =" red_background"> Hello World< / h1>
< h1>< img src =" red.gif" />< / h1>

等...

任何人都可以帮助我吗?
>Hello... I''m trying to write a regular expression to match the content
of a html tag.

I need to match the content of <h1i.e.

<h1>Hello World</h1>
<h1 class="red_background">Hello World</h1>
<h1><img src="red.gif"/></h1>

etc...

can anyone help me?



尝试这种模式:


#< h1 [^>] *>(。+?)< ; / h1>#


Micha


Try this pattern:

#<h1[^>]*>(.+?)</h1>#

Micha



它正在工作!!谢谢!

It''s working!! thanks!


nintesa写道:
nintesa wrote:

你好......我正在尝试写一个正则表达式匹配内容

的html标签。


我需要匹配< h1i.e的内容。


< h1> Hello World< / h1>

< h1 class =" red_background"> Hello World< / h1>

< h1> ;< img src =" red.gif" />< / h1>


等...


任何人都可以帮帮我?


谢谢!
Hello... I''m trying to write a regular expression to match the content
of a html tag.

I need to match the content of <h1i.e.

<h1>Hello World</h1>
<h1 class="red_background">Hello World</h1>
<h1><img src="red.gif"/></h1>

etc...

can anyone help me?

Thanks!!



preg_match(''|< h1。*?>(。*?)< / h1> |'',

preg_match(''|<h1.*?>(.*?)</h1>|'',


这篇关于对preg_match有点帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆