DecisionToolkit/dsntk-rs

Handle `q` flag in regular expressions

Opened this issue · 0 comments

Source: https://www.w3.org/TR/xpath-functions-31/

q: if present, all characters in the regular expression are treated as representing themselves, not as metacharacters. In effect, every character that would normally have a special meaning in a regular expression is implicitly escaped by preceding it with a backslash. Furthermore, when this flag is present, the characters $ and \ have no special significance when used in the replacement string supplied to the fn:replace function. This flag can be used in conjunction with the i flag. If it is used together with the m, s, or x flag, that flag has no effect.

Examples:
fn:tokenize("12.3.5.6", ".", "q") returns ("12", "3", "5", "6")
fn:replace("a\b\c", "", "\", "q") returns "a\b\c"
fn:replace("a/b/c", "/", "$", "q") returns "a$b$c"
fn:matches("abcd", ".*", "q") returns false()
fn:matches("Mr. B. Obama", "B. OBAMA", "iq") returns true()