Code
Match a PascalCase identifier
Match class-style names like UserAccount or HttpClient.
Pattern
Regular expression
\b[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)+\bHow it works
Starts with a capital letter followed by lowercase/digits, then one or more additional capitalized segments. Excludes single-word capitals like `User`.
Matches
- ▸UserAccount
- ▸HttpClient
- ▸MyClass123
Non-matches
- ▸User (single word)
- ▸userAccount (starts lower)
Language snippets
JavaScript
const re = /\b[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)+\b/g;Python
re.findall(r"\b[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)+\b", text)Go
re := regexp.MustCompile(`\b[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)+\b`)Java
Pattern.compile("\\b[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)+\\b")Frequently asked questions
What is the regex for PascalCase identifier?
The pattern \b[A-Z][a-z0-9]+(?:[A-Z][a-z0-9]+)+\b matches PascalCase identifier. Starts with a capital letter followed by lowercase/digits, then one or more additional capitalized segments. Excludes single-word capitals like `User`.
What does this PascalCase identifier pattern match?
It matches strings like UserAccount, HttpClient, MyClass123, but rejects User (single word), userAccount (starts lower).
How do I use this pattern in JavaScript, Python, Go, Java?
Ready-to-run snippets are provided for JavaScript, Python, Go, Java. Copy the one for your language from the Language snippets section — each wraps the same core pattern in that language's regex API.