A character class matches one character chosen from a set. Write the choices between square brackets: `[hH]ello` matches `hello` or `Hello` because `[hH]` matches either form of the first letter. section 16.2
Inside the brackets, choices can be individual characters or ranges:
- `[a-z]` matches one lowercase letter; `[0-9A-Z]` matches one digit or uppercase letter. section 16.2
- Put a literal hyphen first so it is not read as a range: `[-012]` matches `-`, `0`, `1`, or `2`. section 16.2
Matching name characters
`[-a-zA-Z]` matches one hyphen or letter. Add `+` to match one or more such characters: `[-a-zA-Z]+` can match `McDonald` or `Perkin-Elmer`. It can also match `---`, so this pattern alone does not establish that a match is a valid name. section 16.4
Character classes can be combined with other regex constructs. In a contact-record pattern, `[-a-zA-Z]+` supplies each name component, while groups and `?` handle an optional middle name or area code. Outside a character class, the hyphens separating phone-number digits are ordinary hyphens. section 16.4








