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 Expression | Match | Not a Match |
---|---|---|
a[^bcd]ef | axef, akef | abef, acef, adef, axkef |
a[^b-d]ef | axef, akef | abef, acef, adef, axkef |
file[^1-2][0-9]? | file3, file45 | file, 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.