Uses old Rust 2015
1.0.0 |
|
---|
#132 in #escaping
6KB
Escape Regex
Escape regular expression special characters in order to make it able to be concatenated safely by users.
Example
extern crate escape_regex;
extern crate regex;
use regex::Regex;
let pattern = "123*456";
let escaped_pattern = escape_regex::escape_string(pattern);
let reg = Regex::new(&escaped_pattern).unwrap();
assert_eq!(true, reg.is_match("0123*4567"));
Crates.io
https://crates.io/crates/escape-regex
Documentation
License
lib.rs
:
Escape Regex
Escape regular expression special characters in order to make it able to be concatenated safely by users.
Example
extern crate escape_regex;
extern crate regex;
use regex::Regex;
let pattern = "123*456";
let escaped_pattern = escape_regex::escape_string(pattern);
let reg = Regex::new(&escaped_pattern).unwrap();
assert_eq!(true, reg.is_match("0123*4567"));