What's the PCRE2 regular expression syntax to match a specific word if and only if it contains at least one uppercase letter? I can currently match both conditions individually (^foobar$
or [A-Z]+
), but don't know how to combine as a compound conditional.
Expected results for testing "foobar":
✅ Foobar ✅ fooBAR ❌ foobar ❌ Foobars ❌ sFoobar
Positive lookahead assertions (?=...)
and local options (?i:...)
can be used:
^(?=.*[A-Z])(?i:foobar)$