I am writing data entry routines for an application, and would
like to validate input for a JTextField according to a regular
expression - this means not only validation upon entry of the
whole string (end of edit), but validation with character-by-
character input.

The problem is that a partial string is likely to be invalid
according to a regular expression, but not break the rules for
partial matching according to that expression.


If the regular expression is

The string "a" would be neither a partial or whole match.
The string "0" would be a partial match, not a whole one.
The string "00" would be both a partial and a whole match.

I have been using GNU's regular expression package for Java,
(see www.cacas.org/java/gnu/regexp/) which is excellent but
does not seem to provide for validation in this way.
Masks on input (Eg. date is seen as __-__-__) are not
sufficient for my purposes as these enforce length
restrictions on the string, and rarely provide any further
intelligence for validation.

Any ideas?