Created
January 27, 2017 15:35
-
-
Save tomaszpolanski/3f600f63effc5ac149b4f3b03b130737 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tool to nicely validate your regex: http://www.regexpal.com/ | |
// Empty java regex | |
//g | |
// Single letter | |
/T/g | |
// Testing | |
/T/g.test('T') | |
// The rest of the examles do not contain '//g' | |
// Exact string - 'Tomek' | |
Tomek | |
// Line starting with given string - 'Tomek is the author' | |
^Tomek | |
// Single digit - '1' | |
\d | |
// Single, any chara character | |
. | |
// Exactly one digit in the begining - '1' | |
^\d{1} | |
// Exactly one or two digit in the begining - '1' | |
^\d{1,2} | |
// Two or more digit in the begining - '234' | |
^\d{2,} | |
// Zero or more digits | |
\d* | |
// One or more digits | |
\d+ | |
// Zero or one digit | |
\d? | |
// Only one of given characters in the begining - 'c' | |
^[abc] | |
// Or another way | |
^[a-c] | |
// One of the choices - 'cd' | |
ab|cd | |
// Groups: catching the number - 'I am 31 yers old' | |
(\d{1,}) | |
// Date validation - '1970-01-01T10:00:00Z' | |
/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment