Prerequisite - I suggest you familiarize yourself with formal languages, tokens and set theory. These will really help you understand the core concepts behind regular expressions.

Regular expressions or regexps are a way to specify formal languages, their tokens generally consist of ASCII characters. Regexps can be very useful for string pattern matching and have various practical functionality to offer if used correctly. Depending on how you incorporate this into your project it can be used as a way to pattern match user inputs - block banned key characters, regulate format, search and retrieve specific information from meta-data.

One you have the basic syntax down, writing complicated regexps can become very simple. To begin with ill introduce some very basic syntax, some examples to help you visualize the process and how to construct larger regexps patterns.

Regexp syntax

  .   Single character match except newline
"." Anything in quotations marks literally
A* Zero or more occurrences of A
A+ One or more occurrences of A
A? Zero or one occurrence of A
A/B Match A only if followed by B
() series of regexps grouped together
[] Match any character in brackets
[^] Do not match any character in brackets
[-] Define range of characters to match
^ Match beginning of new line
$ Match end of a line
{} Cardinality of pattern match set
\ Escapes meta-characters
| Disjunctive matches, or operation match

Examples

Now to put this syntax to text.