qtil
advanced-security/qtil-swift 0.0.3
Search

Predicate escapeRegex

Add escapes to a string literal to make it safe for use in a Java-style PRCE regex, as a direct character by character match.

For instance, regexEscape("foo") = "foo", and regexEscape("^foo(bar)baz[qux]$") = "\\^foo\\(bar\\)baz\\[qux\\]\\$".

To unescape the result of this function back to itself, use the module Escape<regexEscapeMap/2>. An unescapeRegex function is not provided, as the name may be misleading.

Import path

import qtil.strings.Escape
string escapeRegex(string str)