An regular expression is written in the form of pattern or modifiers where pattern is the
regular expression itself and modifiers are a series of characters indicating various options. The "modifiers" part is optional.
There are characters which have special use in regular exps : [ \ ^ $ . | ? * + ( ).
There are Manely two methods for creating a RegExp object.
- RegExp Literal
- RegExp Object Constructor
var pattern = new RegExp(pattern, modifiers);
var pattern = /pattern/modifiers;
Brackets are used to find a range of characters :
|| It matches any character from lowercase a through lowercase z.
|| Find any character between the brackets
|| It matches any character from uppercase A through uppercase Z.
||Find any character NOT between the brackets
|| Find any of the alternatives specified
|| It matches any decimal digit from 0 through 9.
Modifiers used in reg() :
|| its Perform a case-insensitive matching
|| Global Search
|| its Perform a global match that's find all matches rather than stopping after the first match.
||its Perform a multiline matching
Regular Expression Quantifiers :
||0 or more
||1 or more
|| 0 or 1
|| Between 2 and 5
|| 2 or more
Literal characters :
||The NUL character (\u0000)
|| Form feed (\u000C)
||Carriage return (\u000D)