Regular Expressions, Partial Strings


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Regular Expressions, Partial Strings

Hybrid View

  1. #1
    Paul Balmforth Guest

    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


  2. #2
    ig Guest

    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


  3. #3
    Paul Clapham Guest

    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
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center