\d any Digit
. any Character
. Period
[abc] Only a, b, or c
[^abc] Not a, b, nor c
[a-z] Characters a to z
[0-9] Numbers 0 to 9
{m} m Repetitions
{m,n} m to n Repetitions
eg. a{1,} means >=1 occurance of a
* Zero or more repetitions
+ One or more repetitions
eg. [abc]+ means >=1 occurance of a or b or c
? Optional
eg. ab?c matches abc or ac
\s any Whitespace
\t any tab
\n any new line
^…$ Starts and ends
() capture Group
(a(bc)) capture Sub group
eg. ^(IMG\d+).png$ matches an image file name
(.*) capture Variable content
(a|b) Matchs a or b
metacharacters
\w any Alphanumeric character
\W any Non-alphanumeric character
\d any Digit
\D any Non-digit character
\s any Whitespace
\S any Non-whitespace character
Last but not least: .* matches anything
【Tech】 Regular Expression Learning Notes
Author:
Permalink: https://mar2ndx.github.io/2015/05/24/unclemartian-regex-tutorial/
License: Copyright (c) 2019 CC-BY-NC-4.0 LICENSE
Slogan: Do you believe in DESTINY?