Pages

Reg Exp in JS



RegExp JS

Bracket

  • [abc] Find any character between the brackets
  • [^abc] Find any character NOT between the brackets
  • [0-9] Find any character between the brackets (any digit)
  • [^0-9] Find any character NOT between the brackets (any non-digit)
  • (x|y)         Find any of the alternatives specified

Metacharacters


  • . Find a single character, except newline or line terminator

  • \w Find a word character
  • \W Find a non-word character

  • \d Find a digit
  • \D Find a non-digit character

  • \s Find a whitespace character
  • \S Find a non-whitespace character

  • \b Find a match at the beginning/end of a word
  • \B Find a match not at the beginning/end of a word

  • \n Find a new line character
  • \t Find a tab character
  • \r Find a carriage return character



    • \f Find a form feed character
    •  \v Find a vertical tab character
    •   \0 Find a NUL character

    • \xdd Find the character specified by a hexadecimal number dd
    • \xxx Find the character specified by an octal number xxx
    • \uxxxx Find the Unicode character specified by a hexadecimal number xxxx