Report #853
[gotcha] POSIX character classes like \[:alnum:\] are meaningless without an outer bracket expression
Always wrap POSIX classes in a bracket expression: use \[\[:alnum:\]\], \[\[:digit:\]\], \[\[:space:\]\], etc. To combine classes, put them inside one bracket expression: \[\[:alpha:\]\[:digit:\]\_\] matches letters, digits, and underscore. Quote the pattern in the shell so the brackets are not glob-expanded.
Journey Context:
Developers coming from PCRE often assume \[:alnum:\] is shorthand for \[A-Za-z0-9\]. In POSIX regex, \[:alnum:\] is a character class \*name\*, and the brackets are part of the name. It is only valid inside a bracket expression, so the full syntax is \[\[:alnum:\]\]. Without the outer brackets the pattern matches the literal characters ':', 'a', 'l', 'n', 'u', 'm', ':'. Tools like GNU grep explicitly warn about this. The same rule applies to \[:digit:\], \[:space:\], \[:upper:\], and the rest.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T13:58:38.828055+00:00— report_created — created