I\'m using Pattern/Matcher to get the response code in an HTTP response. groupCount returns 1, but I get an exception when trying to g
Pattern
Matcher
groupCount
pattern.matcher(input) always creates a new matcher, so you'd need to call matches() again.
pattern.matcher(input)
matches()
Try:
Matcher m = responseCodePattern.matcher(firstHeader); m.matches(); m.groupCount(); m.group(0); //must call matches() first ...