Exclude a Set of Literal Characters ( [^ ] )

You can put a set of literal characters inside square brackets, proceeded by a circumflex (^). The pattern matches only if none of the set of characters is found.

Regular ExpressionMatchNot a Match
a[^bcd]efaxef, akefabef, acef, adef, axkef
a[^b-d]efaxef, akefabef, acef, adef, axkef
file[^1-2][0-9]?file3, file45file, file1, file10

Get Spring Into Linux® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.