Pattern-matching meta characters

Regular expressions are made up of normal characters and metacharacters. Normal characters include upper and lower case letters and numbers

Regular expression pattern-matching can be performed with either a single character or a pattern of one or more characters in parentheses, called a character pattern. Metacharacters have special meanings, as described in the following table.

Table 1. Pattern-matching metacharacters
Pattern-matching metacharacter Description Example
* This metacharacter matches zero or more instances of the preceding character or character pattern. The pattern goo* matches my godness, my goodness, and my gooodness, but not my gdness.
+ This metacharacter matches one or more instances of the preceding character or character pattern. The pattern goo+ matches my goodness and my gooodness, but not my godness.
? This metacharacter matches zero or one instance of the preceding character or character pattern. The pattern goo? matches my godness and my goodness, but not my gooodness or my gdness.
$ This metacharacter matches the end of the string. The pattern end$ matches the end, but not the ending.
^ This metacharacter matches the beginning of the string. The pattern ^severity matches severity level 5, but not The severity is 5.
. This metacharacter matches any single character. The pattern b.at matches baat, bBat, and b4at, but not bat or bB4at.
[abcd] This metacharacter matches any characters in the square brackets or in the range of characters separated by a hyphen (-), such as [0-9]. ^[A-Za-z]+$ matches any string that contains only upper or lower case letter characters.
[^abcd] Matches any character except those in the square brackets or in the range of characters separated by a hyphen (-), such as [0-9]. [^0-9] matches any string that does not contain any numeric characters.
() This metacharacter indicates that the characters in the parenthesis should be treated as a character pattern. A(boo)+Z matches AbooZ, AboobooZ, and AbooboobooZ, but not AboZ or AboooZ.
| This metacharacter matches one of the characters or character patterns on either side of the vertical bar. A(B|C)D matches ABD and ACD, but not AD, ABCD, ABBD, or ACCD.
\ The backslash escape character indicates that the metacharacter following should be treated as a regular character. The metacharacters in this table require a backslash before them if they appear in a regular expression.

To match an opening square bracket, followed by any digits or spaces, followed by a closed bracket, use the following regular expression:

\[[0-9 ]*\].