Regular Expression

Regular Expression

28 August, 2020

A regular expression is a group of characters or symbols which is used to find a specific pattern in a text.


Meta Characters

meta chardesc
.match any single character except for linebreak
[]char class. matches any char contained between the brackets
[^ ]negated char class. matches any character NOT contained between the brackets
*matches 0 or more repetitions of the preceeding symbol
+match one or more repetitions of preceeding symbol
?makes the preceeding symbol optional
{n,m}match at least n but not more than m repetitions of preceeding symbol
(abc)char group
\escapes character
^beginning of the input
$end of the input

Things to Remember

set character range by using hyphen inside character class. Example: /[a-z0-9]/.

a period inside a char set means a literal period

the * (star) with a . (dot) can be used to match any string of characters. Example: .*

braces(also called quantifiers) are used to specify the number of times a character or a group of character can be repeated. Examples:

abdus s. azad
About the Author
Abdus is a Software Engineer working at Level. In his free time, he likes to play with Linux-based machines. Contact him at