protected static String extractParameter(CharSequence response, Pattern regexPattern,
                                             boolean required)
        throws OAuthException {
        val matcher = regexPattern.matcher(response);
        if (matcher.find()) {
            return matcher.group(1);
        }

        if (required) {
            throw new OAuthException(
                "Response body is incorrect. Can't extract a '" + regexPattern.pattern()
                    + "' from this: '" + response + "'", null);
        }

        return null;
    }
<p>extractParameter.</p>

@param response a {@link String} object
@param regexPattern a {@link Pattern} object
@param required a boolean
@return a {@link String} object
@throws OAuthException if any.
pac4j-oauth/src/main/java/org/pac4j/oauth/profile/qq/QQProfileDefinition.java