Regular expressions are used for defining String patterns that can be used for searching, manipulating and editing a text.

These expressions are also known as Regex (short form of Regular expressions).

Regular expressions have twelve characters have special meanings:

1. the backslash \; 2. the caret ^; 3. the dollar sign $; 4. the period or dot .; 5. the vertical bar or pipe symbol |; 6. the question mark ?; 7. the asterisk or star *; 8. the plus sign +; 9. the opening parenthesis (; 10. the closing parenthesis ); 11. the opening square bracket [; 12. and the opening curly brace {.

These special characters are often called "metacharacters". If you want to use any of these characters as a literal in a regex, you need to escape them with a backslash.

Character Classes or Character Sets

A "character class" matches only one out of several characters. To match an a or an e, use [ae].

You can use a hyphen inside a character class to specify a range of characters.

Typing a caret after the opening square bracket negates the character class.

Shorthand Character Classes

\d matches a single character that is a digit,

\w matches a "word character" (alphanumeric characters plus underscore), 

\s matches a whitespace character (includes tabs and line breaks).

Non-Printable Characters

You can use special character sequences to put non-printable characters in your regular expression.

Use:

\t - to match a tab character (ASCII 0x09),

\r - for carriage return (0x0D),

\n - for line feed (0x0A).

The Dot Matches (Almost) Any Character

The dot matches a single character, except line break characters.

Anchors

Anchors do not match any characters. They match a position.

^ matches at the start of the string, and $ matches at the end of the string.

Alternation (|)

Alternation is the regular expression equivalent of "or".

Repetition

The question mark makes the preceding token in the regular expression optional.

Grouping and Capturing

Place parentheses around multiple tokens to group them together.

Quantifiers

* matches any number of what's before it, from zero to infinity,
? matches zero or one,
+ matches one or more.

References & further readings:

  1. Regular expression From Wikipedia
  2. Regular-Expressions.info
  3. Regular expressions from The Modern JavaScript Tutorial
  4. JavaScript RegExp Reference from W3Schools
  5. Regular Expressions and RegExp Object from Tutorials Point

Regex Cheat Sheets

  1. Regular expressions - An introduction
  2. Quick-Start: Regex Cheat Sheet
  3. Regex tutorial — A quick cheatsheet by examples
  4. Regex cheatsheet
  5. Ultimate Regex Cheat Sheet
  6. Regular expression syntax cheatsheet
  7. Python Regex Cheatsheet
  8. re — Regular expression operations

Regular Expression Testers

  1. Regular Expression Tester from FreeFormatter
  2. RegEx Testing From Dan's Tools
  3. Regular expression tester
  4. Regexe - online regular expressions testing
  5. Regex Tester from ExtendsClass
  6. Regular Expression Tester from WhatsMyIP
  7. Regular Expression Tester from Web Toolkit Online
  8. Javascript Regex Testing
  9. Online tool to test regular expressions in JavaScript
  10. Testing Python regular expressions from pythex
  11. Regex Tester