maybe you can refactor this part of code to use Matcher.matches() instead of string.matches()?