homeprojectstutorialsbooksmusicaboutblue
Regular Expressions Syntax Explained


To see the syntax, usage and explanation of a particular symbol, you can click on it.



^(Carret)

Meaning: Matches the start of the string represented by the regular expression.

Usage/Example: ^ matches the a in abc


$(Dollar sign)

Meaning: Matches the end of the string represented by the regular expression.

Usage/Example: $ matches the c in abc


.(Dot)

Meaning: Matches any single character.

Usage/Example: . matches any single character x which is not a character with special meaning.


\(Backslash)

Meaning: Escapes the special meaning of special characters : ([\^$.|?*+()].

Usage/Example: When used before any special character it escapes the special meaning of that character and presents it as an ordinary character.


[](Square brackets)

Meaning: Starts and Closes a character class.

Usage/Example: [abc] matches a, b or c.


-(Hyphen)

Meaning: Specifies a range of characters.

Usage/Example: [a-zA-Z0-9] matches any letter of digit.


[^(Combination of [ and ^)

Meaning: When ^ is used immediatly after the opening [ , it negates the specified character class.

Usage/Example: [^a-c] matches any character except a, b or c.


|(Pipe symbol)

Meaning: Matches either one of the parts bordered with |.

Usage/Example: abc|def|xyz matches abc, def or xyz.


?(question mark)

Meaning: Makes the preceding term optional.

Usage/Example: abc? matches abc or ab.


*(Asterisk)

Meaning: Repeats the preceding term zero or more times.

Usage/Example: a* can match nothing or a+(a, aa, aaa, aaaa....)


+(Plus sign)

Meaning: Repeats the previous term once or more times.

Usage/Example: a+ matches a, aa, aaa, aaaa....


{n}(where n>=1)

Meaning: Repeats the previous term exactly n-times.

Usage/Example: a{3} matches aaa.


{n,m}(where n>=1; m>=n)

Meaning: Repeats the previous term between n and m times.

Usage/Example: a{3,5} matches aaa, aaaa or aaaaa.


{n,}(where n>=1)

Meaning: Repeats the previous term atleast n-times.

Usage/Example: a{2,} matches aa, aaa, aaaa, aaaaa....


Have anything to say? Drop me a note in my inbox.