php 正则表达式正则表达式一般表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 正则表达式正则表达式一般表相关的知识,希望对你有一定的参考价值。

match anything
.*
match html tags and all it's content
<.*>
matching html tags only non-greedy
<.*?>

match any 3 digit number
\d{3} 

match 5 or more digits numbers
/d{5,}

match all the white space 
\s

match all the spaces that aren't white space
\S 

match all the digit spaces
\d

all the non digit characters
\D

match word (not special characters)
\w
match non word (special characters and spaces)
\W

select characters 'a' or 'b'
(a|b)

match all characters of 123
[123]

match not these characters 123
[^123]

mach range of letters a-z
[a-z]

group match or capture match
(hello)(world)

match special charaters have to backslash


testing
this will match this
<div class="ratings-bar">(.*?)<\/span>

<div class="ratings-bar">
<div class="inline-block ratings-imdb-rating" name="ir" data-value="7.2"><span class="global-sprite rating-star imdb-rating"></span>



abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
01234567890 _+-.,!@#$%^&&*();\/|<>"'
<strong>Hello World</strong>
12345 -98.7 3.141 .6180 9,000 +42
555.123.4567	+1-(800)-555-2468
foo@demo.net	bar.ba@test.co.uk
www.demo.com	http://foo.co.uk/
<span class="certificate">PG-13</span>
http://reger.com/foo.html?q=bar
https://mediatemple.net

以上是关于php 正则表达式正则表达式一般表的主要内容,如果未能解决你的问题,请参考以下文章

php的问题

php正则表达式

浅析php的正则表达式

请问java的正则表达式和php的正则表达式通用吗

PHP正则表达式基本函数

PHP正则匹配 Emoji的表达式怎么写?