DevKits

Code

Match a camelCase identifier

Match variable names in camelCase like userName or fooBar42.

Pattern

Regular expression

\b[a-z]+(?:[A-Z][a-z0-9]*)+\b

How it works

Starts with lowercase word, then one or more segments starting with an uppercase followed by lowercase/digits. Requires at least one internal capital.

Matches

  • userName
  • fooBar42
  • getUserById

Non-matches

  • User (starts uppercase)
  • lower (no internal capital)
  • snake_case

Language snippets

JavaScript

const re = /\b[a-z]+(?:[A-Z][a-z0-9]*)+\b/g;

Python

re.findall(r"\b[a-z]+(?:[A-Z][a-z0-9]*)+\b", text)

Go

re := regexp.MustCompile(`\b[a-z]+(?:[A-Z][a-z0-9]*)+\b`)

Java

Pattern.compile("\\b[a-z]+(?:[A-Z][a-z0-9]*)+\\b")

Related patterns

Try any pattern live in the Regex Tester