

The first tools that used regular expressions were line-based. This exception exists mostly because of historic reasons. So by default, the dot is short for the negated character class (UNIX regex flavors) or (Windows regex flavors). In all regex flavors discussed in this tutorial, the dot will not match a newline character by default. The only exception are newline characters. The dot matches a single character, without caring what that character is.

Unfortunately, it is also the most commonly misused metacharacter. In regular expressions, the dot or period is one of the most commonly used metacharacters. Again, the order of the characters and the ranges does not matter. matches a hexadecimal digit or the letter X. You can combine ranges and single characters. matches a single hexadecimal digit, case insensitively. You can use a hyphen inside a character class to specify a range of characters. The order of the characters inside a character class does not matter.

gry will not match graay, graey or any such thing. Very useful if you do not know whether the document you are searching through is written in American or British English.Ī character class matches only a single character. You could use this in gry to match either gray or grey. Simply place the characters you want to match between square brackets. With a “character class”, also called “character set”, you can tell the regex engine to match only one out of several characters.
