May 14, 2021
Regex 101
Playground
=> Start with word
=> End with word
=> Match any of
=> Match any letters/numbers
=> Refuse any number
=> Specify an optional letter/word 0 or 1
=> Specify an optional letter/word 0 or ++
=> Specify a mandatory letter/word
=> Specify range | ? === {0,1} | + === {1,} | * === {0,}
=> Quantifiers
- *: 0 or more
- +: 1 or more
- ?: 0 or 1
- {3: Exactly 3
- {3,}: 3 or more
- {3,5}: 3, 4 or 5
=> Pattern Modifiers
- g: Global match
- i: Case-insensitive
- m: Multi-line mode. Causes ^ and $ to also match the start/end of lines.
- s: Single-line mode. Causes . to match all, including line breaks.
- x: Allow comments and whitespace in pattern
- e: Evaluate replacement
- U: Ungreedy mode
=> Shortcuts
- \d: [0-9]
- \D: [^0-9]
- \w: [a-zA-Z0-9_]
- \W: [^a-zA-Z0-9_]
- \t: tab
- \n: newline
- \r: backspace
- \s: whitespace
- \S: nor \n \s \t
- .: everything
- frenchTelephoneNumber: ^0[1-68]([-. ]?[0-9]{2}){4}$
- email: ^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$