Matching Any in a Set of Characters
[ .. ]
When a list of characters are enclosed in square braces [..] then any character in that set will be matched.
Example: [abc] matches a, b, and c, but not d.
When a caret ^ appears at the beginning of the set, the match succeeds only if the character is not in the set.
Example: [^abc] matches d, e, or f, but not a, b, or c.
Sets can conveniently be described with a range. A range is specified by two characters separated by a dash, such as [a-z]. The beginning character must have a lower ASCII value than the ending character.
Example: [a-z] matches any character in the range a through z, but not A or 1 or 2.
Sets can contain multiple ranges.
Example 1: [a-zA-Z] matches any alphabetic character.
Example 2: [^a-zA-Z0-9] matches any non-alphanumeric character.