Regex for PascalCased words (aka camelCased with leading uppercase letter)

([A-Z][a-z0-9]+)+

Assuming English. Use appropriate character classes if you want it internationalizable. This will match words such as “This”. If you want to only match words with at least two capitals, just use

([A-Z][a-z0-9]+){2,}

UPDATE:
As I mentioned in a comment, a better version is:

[A-Z]([A-Z0-9]*[a-z][a-z0-9]*[A-Z]|[a-z0-9]*[A-Z][A-Z0-9]*[a-z])[A-Za-z0-9]*

It matches strings that start with an uppercase letter, contain only letters and numbers, and contain at least one lowercase letter and at least one other uppercase letter.

Leave a Comment