Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: REGEX For Uppercase Alphanumeric

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default REGEX For Uppercase Alphanumeric

    Hi All,

    I am in need of regex for alphanumeric (uppercase only) values which will verify string of length 5below

    ABCCD - False
    AB12C - True
    ABC12 - True
    12ABC - True
    12345 - False

    If it contain any lowercase then it should result in false as well.

    My regex ^[A-Z0-9]{5}$ is not working for above type of values.

    Thanks
    Raj


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: REGEX For Uppercase Alphanumeric

    One way to do this would be to split it up into multiple regular expressions: one to make sure it doesn't contain lowercase letters, one to make sure it contains at least one number, and one to check the length.

    I'm not a regular expression wizard, so there might be a way to roll that all up into one, but it didn't immediately occur to me.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. The Following User Says Thank You to KevinWorkman For This Useful Post:

    Raj4Smile (April 17th, 2014)

  4. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: REGEX For Uppercase Alphanumeric

    K Kevin, Thanks will try. But I still need help.

    Rohit

  5. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: REGEX For Uppercase Alphanumeric

    Quote Originally Posted by Raj4Smile View Post
    K Kevin, Thanks will try. But I still need help.
    If you're splitting it up into multiple regular expressions, which one is giving you trouble now?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. How to determine if a String has non-alphanumeric characters?
    By JAVAHELPP in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 11th, 2013, 07:39 PM
  2. Writing an Action Event in a Jpanel to convert user text entered in a textField to uppercase
    By veryNoviceProgrammer in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 24th, 2013, 07:48 PM
  3. Replies: 4
    Last Post: November 28th, 2012, 03:01 PM
  4. Uppercase and Lowercase in a string
    By sselasky1 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 16th, 2012, 03:01 PM
  5. Listing the alphabet in lower and uppercase
    By Nemphiz in forum Object Oriented Programming
    Replies: 2
    Last Post: May 25th, 2010, 05:25 PM

Tags for this Thread