-
Notifications
You must be signed in to change notification settings - Fork 50
Is there a MULTILINE support for hyperscan? #213
Copy link
Copy link
Open
Description
HS_FLAG_MULTILINE does not seem to have any impact in java API.
public class Validator {
private static final EnumSet<ExpressionFlag> flags = EnumSet.of(ExpressionFlag.CASELESS, ExpressionFlag.PREFILTER, ExpressionFlag.MULTILINE);
private static boolean isRegexValidHyperscan(String regex) {
Expression expression = new Expression(regex, flags);
Expression.ValidationResult result = expression.validate();
if (result.getErrorMessage() != null) System.out.println(result.getErrorMessage());
return result.isValid();
}
private static boolean isRegexValidJava(String regex) {
try {
Pattern.compile(regex, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
return true;
} catch (PatternSyntaxException e) {
e.printStackTrace();
return false;
}
}
public static void main(String[] args) throws Exception {
String regex = "\\d{13}^[A-Z]{1}";
boolean regexValidHyperscan = isRegexValidHyperscan(regex);
System.out.println(regex + " valid by hyperscan: " + regexValidHyperscan);
boolean regexValidJava = isRegexValidJava(regex);
System.out.println(regex + " valid by java: " + regexValidJava);
}
}produces
Embedded start anchors not supported.
\d{13}^[A-Z]{1} valid by hyperscan: false
\d{13}^[A-Z]{1} valid by java: true
@gliwka from what I read it should from the doc it should ve a valid regex, right?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels