Some basics about Regular Expressions

What is a Regular Expression?

A regular expression (regex or regexp for short) is a special text string for describing a search pattern. Regular expression is written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.

Regular expressions in JavaScript take
the form:
var RegEx = /pattern/modifiers;
/g   Global matching
/i    Case insensitive
/s   Single line mode
/m   Multi line mode
^ Start of string
$ End of string
. Any single character
(a|b) a or b
(…) Group section
[abc] Item in range (a or b or c)
[^abc] Not in range (not a or b or c)
a? Zero or one of a
a* Zero or more of a
a+ One or more of a
a{3} Exactly 3 of a
a{3,} 3 or more of a
a{3,6} Between 3 and 6 of a
!(pattern) “Not” prefix. Apply rule when URL does not match pattern.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s