Regular Expression
Regular Expression
What It Matches Matches any character except newline Matches any single character in set Matches any single character not in set Matches one digit Matches a non-digit, same as [^09] Matches an alphanumeric (word) character Matches a non-alphanumeric (non-word) character Matches a null character Matches a backspace Matches a formfeed Matches a newline Matches a return Matches whitespace character, spaces, tabs, and newlines Matches non-whitespace character Matches a tab Matches to beginning of line Matches to end of line Matches the beginning of the string only Matches a word boundary (when not inside [ ]) Matches a non-word boundary Matches where previous m//g left off Matches the end of the string or line Matches the end of string only Matches 0 or 1 of x
Metacharacter/Metasymbol X* X+ (xyz)+ X{m,n} was|were|will (string) \1 or $1 \2 or $2 \3 or $3 New with JavaScript 1.5 (?:x)
What It Matches Matches 0 or more of x Matches 1 or more of x Matches one or more patterns of xyz Matches at least m of x and no more than n of x Matches one of was, were, or will Used for backreferencing (see "Remembering or Capturing" on page 443) Matches first set of parentheses Matches second set of parentheses Matches third set of parentheses Matches x but does not remember the match. These are called non-capturing parentheses. The matched substring cannot be recalled from the resulting array's elements [1], ..., [n] or from the predefined RegExp object's properties $1, ..., $9. Matches x only if x is followed by y. For example, /Jack(? =Sprat)/ matches Jack only if it is followed by >Sprat. /Jack(?=Sprat|Frost)/ matches Jack only if it is followed by Sprat or Frost. However, neither Sprat nor Frost are part of the match results. Matches x only if x is not followed by y. For example, /\d+(?!\.)/ matches a number only if it is not followed by a decimal point. /\d+(?!\.)/.exec("3.141") matches 141 but not 3.141.
x(?=y)
x(?!y)