Results 1 to 3 of 3
  1. #1
    MJoe is offline Member
    Join Date
    Jun 2010
    Posts
    1
    Rep Power
    0

    Default Urgent Regular expression to allow only alpha characters and % wildcard

    Hi,

    I need a regular expression to check that only alpha characters
    are entered in a name field search and the wildcard character % Eg: %Joh%

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    isn't this just
    Java Code:
    [A-Za-z\%]+
    see also: Tutorial

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    P.S. Use PreparedStatement. I can almost guarantee that you think you need this because you are cobbling together sql statements from string values. Do not do that. Use PreparedStatement.

    Edit: Besides "_" is also a valid wildcard in sql, and numbers are, of course, also valid. And the "word" characters are 0-9,a-z,A-Z, and "_", so simply "\\w".

Similar Threads

  1. regular expression
    By prof.deedee in forum JDBC
    Replies: 3
    Last Post: 02-19-2010, 11:15 AM
  2. regular expression
    By QkrspCmptPop in forum Advanced Java
    Replies: 8
    Last Post: 01-20-2010, 03:55 AM
  3. regular expression
    By ras_pari in forum Advanced Java
    Replies: 27
    Last Post: 10-07-2009, 12:25 PM
  4. regular expression for unicode
    By tharhan in forum Advanced Java
    Replies: 0
    Last Post: 04-01-2008, 10:53 PM
  5. I can't find the right regular expression
    By romina in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •