JavaScript RegEx

Pattern matching with regular expressions in JavaScript.

Pattern Syntax

var a = str.search(/CheatSheet/i);

Modifiers

i       # perform case-insensitive matching
g       # perform a global match
m       # perform multiline matching

Patterns

\\      # Escape character
\d      # find a digit
\s      # find a whitespace character
\b      # find match at beginning or end of a word
n+     # contains at least one n
n*     # contains zero or more occurrences of n
n?     # contains zero or one occurrences of n
^      # Start of string