1

Matcher m = patternFoo.matcher(sFoo);

if(m.find()){
 ...
 m.start()
 ...
}

I wonder how it is possible for the m.start() in the above code to throw the following exception:

Exception: No successful match so far
Class: java.lang.IllegalStateException
 Stack trace: java.lang.IllegalStateException: No successful match so far
        at java.util.regex.Matcher.ensureMatch(Matcher.java:1116)
        at java.util.regex.Matcher.start(Matcher.java:1158)
        at java.util.regex.Matcher.start(Matcher.java:1130)

Could anyone shed some light on this?

Hong
  • 17,643
  • 21
  • 81
  • 142

0 Answers0