Browse Source

fix REGEX filter

pull/16/head
Jochen Berger 12 years ago
parent
commit
0414296b34
  1. 16
      json-path/src/main/java/com/jayway/jsonpath/Criteria.java

16
json-path/src/main/java/com/jayway/jsonpath/Criteria.java

@ -253,14 +253,16 @@ public class Criteria {
} }
} else if (CriteriaType.REGEX.equals(key)) { } else if (CriteriaType.REGEX.equals(key)) {
final Pattern exp = (Pattern) expectedVal;
return objectOrAnyCollectionItemMatches(actualVal, new Predicate<String>() {
@Override
Pattern exp = (Pattern) expectedVal; public boolean accept(String value) {
String act = (String) actualVal; return value != null && exp.matcher(value).matches();
if (act == null) { }
return false; });
}
return exp.matcher(act).matches();
} else { } else {
throw new UnsupportedOperationException("Criteria type not supported: " + key.name()); throw new UnsupportedOperationException("Criteria type not supported: " + key.name());

Loading…
Cancel
Save