Skip to main content

regex

  • \w - word character: letter, number and underscore characters
  • \W - not word character
  • \d - digits
  • \D - not digits
  • \s - whitespace
  • \S - not whitespace
  • . - any character except line breaks
  • [abc] - character set
  • [^abc] - negated character set
  • [a-z] - range
  • {1,3} - quantifier range
  • \* - expression matches 0 or more
  • \+ - expression matches 1 or more
  • ? - optional
  • ( ) - groups an expression
  • \\ - escape character
  • ^ - select at line start
  • $ - select at line end
  • (?=) - positive lookahead Ex. \d+(?=PM) to get 3 in 4 Aug 3 PM
  • (!?) - negative lookahead (select characters other than those containing...) Ex. \d+(!?PM) to get 4 in 4 Aug 3 PM
  • (?<=) - positive lookbehind (select characters that are preceeded by ...) Ex. (?<=\$)\d+ to get 5 in Product Code: 1064 Price: $5
  • (?<!<) - negative lookbehind (select characters other than those preceeded by ...)

Links to tutorials