正则表达式匹配多行

String exceptionMessage = "These policy alternatives can not be satisfied: \n"
                                      + "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SupportingTokens\n"
                                      + "{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}UsernameToken";
            String exceptionMessagePattern = " (?s).*These policy alternatives can not be satisfied:.*";

            boolean isExceptonMessage = Pattern.matches(exceptionMessagePattern, exceptionMessage);
            System.out.println("--" + isExceptonMessage);
结果是true

你可能感兴趣的:(正则表达式)