diff --git a/json-path/src/main/java/com/jayway/jsonpath/Criteria.java b/json-path/src/main/java/com/jayway/jsonpath/Criteria.java index e43ca4a0..4e31b0f6 100644 --- a/json-path/src/main/java/com/jayway/jsonpath/Criteria.java +++ b/json-path/src/main/java/com/jayway/jsonpath/Criteria.java @@ -253,14 +253,16 @@ public class Criteria { } } else if (CriteriaType.REGEX.equals(key)) { + final Pattern exp = (Pattern) expectedVal; + + return objectOrAnyCollectionItemMatches(actualVal, new Predicate() { - - Pattern exp = (Pattern) expectedVal; - String act = (String) actualVal; - if (act == null) { - return false; - } - return exp.matcher(act).matches(); + @Override + public boolean accept(String value) { + return value != null && exp.matcher(value).matches(); + } + }); + } else { throw new UnsupportedOperationException("Criteria type not supported: " + key.name());