Function regex_to_lark
pub fn regex_to_lark(rx: &str, use_ascii: &str) -> String
Expand description
Make sure given regex can be used inside /…/ in Lark syntax.
Also if use_ascii.contains('d')
replace \d
with [0-9]
and \D
with [^0-9]
.
Similarly for \w
/\W
([0-9a-zA-Z_]
) and \s
/\S
([ \t\n\r\f\v]
).
For standard Unicode Python3 or Rust regex crate semantics use_ascii = ""
For JavaScript or JSON Schema semantics use_ascii = "dw"
For Python2 or byte patters in Python3 semantics use_ascii = "dws"
More flags may be added in future.