[ and ]
The square brackets are metacharacters used in regular expressions to represent a character class. The special meaning of any metacharacters within the brackets is suppressed. The exceptions to this are the ^ (negation) and - (range) metacharacters.
Examples
[abc...] character class, matches any of the characters abc... The special meaning of the . (dot) metacharacter is suppressed and therefore this character class will match abc... not abcxyz.
[^abc...] negated character class, matches any character except abc... and newline.
[a-c] character range, matches any of the characters abc and suppresses the special meaning of any metacharacters.
[^0-9] character range: matches any character that is not a decimal number.
Last modified date: 10/22/2024