Try it out on these example inputs:

back to RegexSwap.

Java class name

Regular expression:

^(([a-z])+.)+[A-Z]([A-Za-z])+$

Categories:

Popularity:

You need to be logged in to cast votes on regexes.

Good
3
Bad
1

Author description and comments (4)

Topic by
kasper

2009-01-22
23:04

Description

Matches a fully qualified Java class name. Requires an Uppercase starting char, which is a commonly followed convention for Java classes.

Matched example:
  • dk.eobjects.datacleaner.gui.DataCleanerGui

Unmatches example:
  • dk.eobjects.datacleaner

Comment by
kasper


Hmm this doesn't work for class names that have digits in them which may be a problem. I have recently been developing on the Jdbc4olap project and the "4" causes the org.jdbc4olap package to not be validated...

Comment by
franklin


As long as it's in the package name it works:
org.foo4bar.FooBar
But this doesn't validate:
org.foobar.Foo4bar

Comment by
cparker


Doesn't validate class names with _ either. Underscore is a valid class name character.

Comment by
kasper


True. Is there a way to exclude underscores from the regex?

You need to be logged in to participate

In order to post your own comments on this regex, you need to be logged in.

Username:

Log in by clicking the login link at the top of the screen