Regex To Match Fully Qualified Class Name In Java

A regular expression to check the plausibility of a fully-qualified class name in Java.

/([a-zA-Z_$][a-zA-Z\d_$]*\.)*[a-zA-Z_$][a-zA-Z\d_$]*/g

Matches:

  • Java.lang.Class
  • Java.lang.Class.forName
  • Java.lang

Non-matches:

  • Java lang.Class.forName
  • Java.lang.Class forName

See Also:

Rate This Regex
Sending
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.