public static List<String> getIssueKeysFromString(String body) { if (isBlank(body)) { return Collections.emptyList(); } final Perl5Util util = new Perl5Util(); //note that we have to create a new match, as MatchResult is not Threadsafe final List<String> result = new ArrayList<String>(); while (util.match(getKeyMatcher().getIssueKeyRegex(), body)) { final MatchResult match = util.getMatch(); // The issue key is composed of the all sub-pattern match // groups after the initial sub pattern match group final int matchGroups = match.groups(); // Check backs from the key to see if it part of the url & URL is ignored if (!getKeyMatcher().isIgnoreUrlWithKey() || !isPartOfUrl(body, match.beginOffset(2))) { result.add(createKeyFromMatchingGroups(matchGroups, match)); } body = body.substring(match.endOffset(matchGroups - 1)); } return Collections.unmodifiableList(result); }
private static boolean isKeyInStringMatchingRegex(final String issueKey, String body) { final Perl5Util util = new Perl5Util(); //note that we have to create a new match, as MatchResult is not Threadsafe while (util.match(getKeyMatcher().getIssueKeyRegex(), body)) { final MatchResult match = util.getMatch(); // The issue key is composed of the all sub-pattern match // groups after the initial sub pattern match group final int matchGroups = match.groups(); final String key = createKeyFromMatchingGroups(matchGroups, match); if (issueKey.equals(key)) { // Check backs from the key to see if it part of the url & URL is ignored if (!getKeyMatcher().isIgnoreUrlWithKey() || !isPartOfUrl(body, match.beginOffset(2))) { return true; } } body = body.substring(match.endOffset(matchGroups - 1)); } return false; }