最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php正则匹配html标签的程序代码
时间:2014-03-28 编辑:简简单单 来源:一聚教程网
正则表达式 |
<(\S*?) [^>]*>.*?\1>|<.*? />
|
---|---|
匹配 | hello|abcd |
不匹配 | abc|123|ddd |
正则表达式 |
^[^<>`~!/@\#}$%:;)(_^{&*=|'+]+$
|
---|---|
匹配 | This is a test |
不匹配 |
正则表达式 |
<!--.*?-->
|
---|---|
匹配 | <!-- <h1>this text has been removed</h1> --> | <!-- yada --> |
不匹配 | <h1>this text has not been removed</h1> |
正则表达式 |
(\[(\w+)\s*(([\w]*)=('|")?([a-zA-Z0-9|:|\/|=|-|.|\?|&]*)(\5)?)*\])([a-zA-Z0-9|:|\/|=|-|.|\?|&|\s]+)(\[\/\2\])
|
---|---|
匹配 | [link url="http://www.domain.com/file.extension?getvar=value&secondvar=value"]Link[/li |
不匹配 | [a]whatever[/b] | [a var1=something var2=somethingelse]whatever[/a] | [a]whatever[a] |
正则表达式 |
href=[\"\'](http:\/\/|\.\/|\/)?\w+(\.\w+)*(\/\w+(\.\w+)?)*(\/|\?\w*=\w*(&\w*=\w*)*)?[\"\']
|
---|---|
匹配 | href="www.yahoo.com" | href="http://localhost/blah/" | href="eek" |
不匹配 | href="" | href=eek | href="bad example" |
正则表达式 |
"([^"](?:\\.|[^\\"]*)*)"
|
---|---|
匹配 | "This is a \"string\"." |
不匹配 | "This is a \"string\". |
正则表达式 |
(?i:on(blur|c(hange|lick)|dblclick|focus|keypress|(key|mouse)(down|up)|(un)?load|mouse(move|o(ut|ver))|reset|s(elect|ubmit)))
|
||
---|---|---|---|
匹配 |
|
||
不匹配 | click | onandon | mickeymouse |
正则表达式 |
(?s)/\*.*\*/
|
---|---|
匹配 | /* .................... */ | /* imagine lots of lines here */ |
不匹配 | */ malformed opening tag */ | /* malformed closing tag /* |
正则表达式 |
<(\S*?) [^>]*>.*?\1>|<.*? />
|
---|---|
匹配 | hello|abcd |
不匹配 | abc|123|ddd |
正则表达式 |
\xA9
|
---|---|
匹配 | © |
不匹配 | anything |
正则表达式 |
src[^>]*[^/].(?:jpg|bmp|gif)(?:\"|\')
|
---|---|
匹配 | src="../images/image.jpg" | src="http://domain.com/images/image.jpg" | src='d:\w |
不匹配 | src="../images/image.tif" | src="cid:value" |
正则表达式 |
/\*[\d\D]*?\*/
|
---|---|
匹配 | /* my comment */ | /* my multiline comment */ | /* my nested comment */ |
不匹配 | */ anything here /* | anything between 2 seperate comments | \* *\ |
正则表达式 |
<[a-zA-Z]+(\s+[a-zA-Z]+\s*=\s*("([^"]*)"|'([^']*)'))*\s*/>
|
---|---|
匹配 | |
不匹配 | | |
-
上一个: php正则匹配a标签的例子
-
下一个: php 生成JSON数据的例子
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24