You need to sign in to do that
Don't have an account?
Markus Koch 7
Regex exception even if matcher.find() is true
Hey guys,
I have an error that I don't get. Here is my code:
What am I doing wrong here? Thanks in advance!
I have an error that I don't get. Here is my code:
pattern contractNumberPattern = pattern.compile('[0-9]{7}'); Matcher contractNumberMatcher = contractNumberPattern.matcher('Test1234567Test'); String contractNumber; system.debug(contractNumberMatcher.find()); system.debug(contractNumberMatcher.matches()); system.debug(contractNumberMatcher.groupCount()); contractNumber = contractNumberMatcher.group(1); system.debug(contractNumber);It should find a 7 digit number inside a string and return this, But even though find() returns true the groupcount is 0 and I get an error when accessing group(1).
What am I doing wrong here? Thanks in advance!