Regular expression: A regular expression is a character string which represents a character sequence. A part of a regular expression which describes a sample of the entire expression is known as pattern. This pattern is matched in a regular expression. Other elements of a regular expression are quantifiers, wildcard characters, and character sets.
Character or literal: A character in a regular expression is known as a literal. It will be matched normally. For Example: a will be matched as a.
Wildcard character: In a regular expression, dot (.) is a wildcard character and it can be used to match any character. For example: . can match a, b, C or any other character.
Quantifier: Quantifier is used to tell how many times a particular expression should be matched.
Some quantifiers are:
+: For matching one or more.
*: For matching zero or more.
?: For matching zero or one.
Example: a+ will match a, aa, aaa, aaaa and so on.
Character sets: Character sets are specified by brackets. For Example: [abc]. It will match a, b, c.
Inverted set: Inverted set is represented by using a ^. For Example: [^abc]. It will match all characters except a,b,c.
Character range: Character range is specified by hyphen: For Example: [1-5]. It will match digits from 1 to 5.
Escape sequences: In a regular expression, standard escape sequences are used. For Example: \n for new line and \t for horizontal tab.