[Previous] [Contents] [Next]


The Dot

One special character, the period or dot character (.), is used in regular expressions to match any single character. Therefore, the regular expression "s.n" matches sun, sin, son, s!n, s%n, and sSn. The dot must, however, match one character. Thus, sn would not match the previous regular expression. To actually match a period character in your string, you must escape the dot with a backslash (\.).

A dot character inside of a character class has no special meaning and is not treated as a metacharacter: It is just used to match a period. For example, to match some common characters seen at the end of a word, we might write [.,:;-'">?!\]].


[Previous] [Contents] [Next]