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 3 of 3

Thread: regular expression issue

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default regular expression issue

    Hi,
    I use the method String.matches(String regex) to find if a string matches the regex expression


    From my point of view the regular expression regex="[0-9]+" means a String that contains at least one figure between 0 and 9

    But when I debug "3.5".matches("[0-9]+") it returns false.

    So what is wrong ?


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: regular expression issue

    Perhaps your point of view is obscured? Did you look into String.matches and see if it does what you think?
    Have you looked at the Pattern class?
    Have you tried to figure out if anything else would work? For example if you changed "3.5" to "3", would it then return true?

  3. #3
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: regular expression issue

    Also at java-forums.org

Similar Threads

  1. [SOLVED] Regular Expression Difficulties...
    By snowguy13 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 4th, 2012, 08:31 AM
  2. advanced regular expression question
    By chopficaro in forum Java Theory & Questions
    Replies: 5
    Last Post: June 8th, 2012, 03:03 PM
  3. Regular expression handling
    By marquiseoflight in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 9th, 2012, 04:57 PM
  4. Regular Expression To Catch Duplicates
    By daniel_el in forum Java Theory & Questions
    Replies: 1
    Last Post: February 7th, 2012, 12:06 PM
  5. Regular Expression help
    By medoos in forum Java SE APIs
    Replies: 0
    Last Post: March 19th, 2011, 07:23 PM