|
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks