This discussion is archived
2 Replies Latest reply: Apr 17, 2013 1:44 AM by sabre150 RSS

Regex

javaMan2012 Newbie
Currently Being Moderated
Hi Folks,

I have posted this in another forum, no reply yet so am posting here as well. I am trying to use regular expression to to see if a certain string value is formatted in the correct way: 'hour:min:sec,milisec'

My code is as follow:

*String format  = "([\\d\\d]:[\\d\\d]:[\\d\\d],[\\d\\d\\d])";*
*boolean found = true;*

*Pattern pattern = Pattern.compile(format);*
*Matcher matcher = pattern.matcher("00:00:03,000");*
*found = matcher.find();*
*System.out.println(found);*

the boolean found is being print as false, I am not sure why, as I was expecting a true as I feel there should have been a match. Hope
someone can advise on this. Thank you.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points