escape

Function escape 

Source
pub fn escape(text: &str) -> String
Expand description

Escapes all special regex characters in a string to make it a literal match.

This function takes a string and returns a new string with all special regex characters escaped with backslashes, so the resulting string can be used as a literal pattern in a regular expression.

ยงExample

use regress::escape;

let escaped = escape("Hello. How are you?");
assert_eq!(escaped, "Hello\\. How are you\\?");

let escaped = escape("$100 + tax (15%)");
assert_eq!(escaped, "\\$100 \\+ tax \\(15%\\)");