Wednesday, February 4, 2009

Regex Syntax

  • .(dot) : matching any character (if the Singleline option is enabled, a dot matches any character including the new line character
  • \w - \W : matching any word character - matching any non-word character
  • \s : matching white-space (white-space is defined as the space character, new line (\n), form feed (\f), carriage return (\r), tab (\t) and vertical tab(\v).
  • \d : matching digits 0-9
  • [] : matching sets of single characters in square brackets
  • [^](caret): added to the start of the set of characters to specifiy that none matching in the set.
  • [1-9] : matching ranges of characters using the hyphen(-). combine ranges of characters togehter as [a-d0-9]
  • *(Star) : matching zero or more times of previous character
  • +(plus) : matching one or more time of previous character
  • ? : matching zero of one times
  • {n} : the minimum number of matches
  • {n,m} : n - the minimum number of mathces, m - the maximum number of matches
  • ^ : matching the start of a string - must be at the beginning of a string
  • $ : matching the end of a string - must be at the end of a string

(P.S. the above are notes after reading the articles online, more details -- see the article: http://www.radsoftware.com.au/articles/regexlearnsyntax.aspx)

No comments:

Post a Comment