C
Christoph
I have a block of code that can be summed up like this
Pattern pat = Pattern.compile("...");
Matcher m = pat.matcher("...");
System.out.println(m.matches());
System.out.println(m.group(1));
The expression matches. But if I comment out the third line (which
only prints "true" and is used for debugging), the group() call
triggers an IllegalStateException - "No match found". If I put it back
in, it works. In a manner of speaking, I need to check whether the
regular expression matches before it actually does.
object was constructed with matcher() - is this not true? Does the
boolean function matches() do something besides returning the boolean
value that *has* to be done before I can access the subgroups?
Pattern pat = Pattern.compile("...");
Matcher m = pat.matcher("...");
System.out.println(m.matches());
System.out.println(m.group(1));
The expression matches. But if I comment out the third line (which
only prints "true" and is used for debugging), the group() call
triggers an IllegalStateException - "No match found". If I put it back
in, it works. In a manner of speaking, I need to check whether the
regular expression matches before it actually does.
impression that the Regular Expression was processed as soon as theFrom reading the documentation (if superficially), I was under the
object was constructed with matcher() - is this not true? Does the
boolean function matches() do something besides returning the boolean
value that *has* to be done before I can access the subgroups?