I am having a problem with the following bit of code. I am trying to match a string. When I have a match everything works perfectly. When it does not find a match it thro
Try checking for a match instead:
if (m.matches()){
instead of:
if (m.group(0) != ""){
http://download.oracle.com/javase/1.5.0/docs/api/java/util/regex/Matcher.html#find() the find method returns true if and only if a match is found. So before you call you have to ensure that matches are found.
if (m.find()) {
// do other stuff
}
This is behaving as documented. You are welcome to catch the exception rather than checking for the empty string.