Crates.io | escape-regex |
lib.rs | escape-regex |
version | 1.0.0 |
source | src |
created_at | 2019-01-07 10:29:57.060111 |
updated_at | 2019-01-07 10:29:57.060111 |
description | Escape regular expression special characters. |
homepage | https://magiclen.org/escape-regex |
repository | |
max_upload_size | |
id | 106012 |
size | 11,400 |
Escape regular expression special characters in order to make it able to be concatenated safely by users.
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"));
https://crates.io/crates/escape-regex