1. Important Links
- Tutorial: https://regexone.com/
- Flowchart generator/Regex Debugger: https://www.debuggex.com/r/7jAhBMayS28ezOAN/4
2. Patterns
2.1. Dates
2.1.1. Basic Date Pattern
^[0-9]{2}-[0-9]{2}-[0-9]{4}$
2.1.2. Pattern: dd-mm-yyyy
Example: 02-01-2016
Generic
^[0-2][0-9]-[0-9][12]-\d{4}$|^[3][01]-[0-9][12]-\d{4}$
Accommodate dots and spaces
^[0-2]\d[-|\.|\/]\d[12][-|\.|\/]\d{4}$|^[3][01][-|\.|\/]\d[12][-|\.|\/]\d{4}$
2.1.3. Pattern: dd-mmm-yyyy
Example: 02 Jan 2016
More refined
^(([0-9])|([0-2][0-9])|([3][0-1]))\ (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\ \d{4}$
Accommodate dots and dashes, check for February
^(([0,1,2][0-9]|3[0,1])[\ \-](Jan|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[\ \-]\d{4})|(([0,1,2][0-9])[\ \-]Feb[\ \-]\d{4})$
2.1.4. Pattern: yyyy-mm-dd hh:ii:ss
Example: 02 Jan 2016 23:59:59
Generic
^\d{4}-[0-1][1-2]-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d$
2.2. Numbers
2.2.1. Decimals
Generic
^\d+\.?\d+$
With negative numbers
^-?\d+\.?\d+$
Complex Numbers
^-?\e?\d+\.?\d+$
2.2.2. Hex Colour
With Hex
^#[0-9|a-f]{6}$
Without Hex
^[0-9|a-f]{6}$
2.2.3. UUID
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
3. Words
3.1. Other
Sample:
Other
Others
other
others
^[o|O]ther[s]?$
3.2. None
Sample:
None
NONE
none
[N|n][O|o][N|n][E|e]
4. Bible
Sample:
John 6
matthew 7:10
genesis 10:10-11
^(\w+) (\d+):?(\d+)?-?(\d+)?