Understanding regular expression metacharacters
When we use special characters in regular expressions, they are called metacharacters because they have a special meaning. They enhance the flexibility, power, and usage of regular expressions. Now, we will discuss the list of metacharacters in regular expressions. All characters, that are not either metacharacters or escape sequences, match themselves in regular expressions. Let's understand each of them in detail.
Quoted metacharacter
A regular expression consisting of a literal or character(letter or digit) is a basic regular expression thatmatches itself.Sometimes, if we need to usethe literal meaning of a metacharacter in a regular expression,weprecede it with a backslash.If a character is preceded by a single backslash, \
, we say the character is quoted.Quoting suppresses the special meaning of a character when matching. For example,if we wantto match the dollar sign, $
, in a string, we need to quote it as follows:
$ echo -e "500$\n500INR...