Appendix D: Regular expressions : Special characters with regular expressions and wild cards
Special characters with regular expressions and wild cards
A wild card character is a special character that represents one or more other characters. The most commonly used wild card characters are the asterisk (*), which typically represents zero or more characters, and the question mark (?), which typically represents any one character.
In Perl-style regular expressions, the period (.) character refers to any single character. It is similar to the question mark (?) character in wild card match pattern. As a result, example.com not only matches example.com but also exampleacom, examplebcom, exampleccom, and so forth.
To match a special character such as “.” and “*” use the backslash ( \ )escape character. For example, to match example.com, the regular expression should be: example\.com
In Perl regular expressions, an asterisk (*) matches the character before it 0 or more times, not 0 or more times of any character. For example, example*.com matches exampleeeeee.com but does not match example.com.
To match any character 0 or more times, use “.*” where “.” means any character and the “*” means 0 or more times. For example, the wild card match pattern exampl*.com should therefore be exampl.*\.com.