Regular Expressions, Partial Strings
Hi.
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.
Eg.
If the regular expression is
[0]{2}
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?
Cheers,
Paul
Re: Regular Expressions, Partial Strings
Hi Paul,
I'm not the authority on this, but java does have a regex package called
java.util.regex; see http://java.sun.com/j2se/1.4/docs/ap.../Pattern.html.
http://www.savarese.org/oro/downloads/ provides the oro matcher. This is
the regex engine used by jpython in its java implementation of Python.
http://www.javaregex.com/ provides a regex engine with Perl5 capabilities.
http://www.meurrens.org/ip-Links/java/regex/ is an index of more java/regex
resources.
--A
Re: Regular Expressions, Partial Strings
I knew that too, but that wasn't the question that Bikhod asked.
PC2
"ig" <igrobyc@juno.com> wrote in message news:3ba40a32$1@news.devx.com...
>
> Hi Paul,
>
> I'm not the authority on this, but java does have a regex package called
> java.util.regex; see
http://java.sun.com/j2se/1.4/docs/ap.../Pattern.html.
>
> http://www.savarese.org/oro/downloads/ provides the oro matcher. This is
> the regex engine used by jpython in its java implementation of Python.
>
> http://www.javaregex.com/ provides a regex engine with Perl5 capabilities.
>
> http://www.meurrens.org/ip-Links/java/regex/ is an index of more
java/regex
> resources.
>
> --A
>