run: http-server -p 2380
view at: http://localhost:2380/demo/
AKA: learning the concept & reasons
/ ... /
/ ... /igm
AKA: learning the commands
/literal/
matches "literal"
.
/.*/
|
/everything|something/
/^pattern/
/pattern$/
/^literal/
will match "literal lesson"
/^literal/
will not match "Something literal"
/^[literal]/
will match anything except "literal"
/literal$/
will match "Something literal"
\
e.g.: \.
/./
matches all characters including whitespaces.
to match lteral period+
matches one or more of preceeding patternl{1,3}
matches one to three repeated instances of letter l?
is used to make a pattern optional
/pie?/
matches pi
\d
vs [0-9]
\w
vs [a-zA-Z]
\D
vs ^[a-zA-Z]
/Greg(ory)?/i
matches greg
and gregory
\1
Used to repeat the previous pattern(?<mygroup>[abc])=\k<mygroup>
same as ([abc])=\1
AKA: Applying the knowledge
hello
except the last
hello helllllllo helllo helo
/hel{2,6}o/
abc123xyz
/\d/
or /[1-3]/
bird. mouse. house
/.*\./
^(http|https):\/\/+[\www\d]+\.[\w]+(\/[\w\d]+)?
AKA: What regex can do for you
neighbo?ur
apologize || apologise
Jan(uary)?
{3}(.)?
/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}/
/^.+@.+$/
/((\<1[\-\. ])?(\(|\<)\d\d\d[\)\.\-/ ] ?)?\<\d\d\d[\.\- ]\d\d\d\d\>/
/\<\d\d\d[\- ]\d\d[\- ]\d\d\d\d\>/
<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>
<title>(.*)</title>
^[ \t]+|[ \t]+$
[ \t\r\n]
^(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$
/\<((\d\d\d\d)[\- ]){3}\d\d\d\d\>/
^[+-]?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$