escape_regex
Escapes regular expression metacharacters (. * + ? ^ $ ( ) [ ] { } | \) in s so it can be
embedded literally in a regex pattern.
This crate has no regex engine of its own; use this before handing s to whichever one you
depend on (regex, fancy-regex, …) when it should be matched character-for-character
instead of as a pattern.
Import
Section titled “Import”Cargo feature string (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
s | &str | The text to escape. |
Returns
Section titled “Returns”String — s with every metacharacter preceded by a backslash.
