sutho100
2/3/2019 - 11:05 PM

Regular expression regex general sheet

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