Swift class regex doesn't support private names (ex. '_Foo')
Author: Kenna-BlackburnCreated Aug 21, 2026Updated Aug 21, 2026
In swift, we have a pattern of naming private things a client can but really shouldn't touch with one or more prefixed underscore.
With the current regex though, it must start with /[A-Z]/, is something like _Foo would not match.
The solution could be as simple as: /\b_*[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/, or /\b(?:_+)?[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/.
Technically swift also supports naming both classes (and funcs and vars) literally anything (even including whitespace) by wrapping the name in backticks (ex. `Foo Bar`), but that's very rarely used and I think can safely be excluded.
Source: PrismJS/prism