1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Functions for directly matching text or adding known regex strings
use ;
use escape;
/// Add matching text to the regex string. Text that is added through this function is automatically escaped.
/// ```
/// let regex_string = human_regex::text("asdf");
/// assert!(regex_string.to_regex().is_match("asdf"));
/// assert!(!regex_string.to_regex().is_match("asddf"));
/// ```
/// Escapes an entire list for use in something like an [or] or an [and] expression.
///
/// See the [cookbook] stop words example for an example of the utility of this function.
/// ```
/// use human_regex::direct::escape_all;
/// let escaped_vec = escape_all(&vec!["et-al", "short-term", "full-scale"]);
/// assert_eq!(escaped_vec, vec![r"et\-al", r"short\-term", r"full\-scale"]);
///```
/// This text is not escaped. You can use it, for instance, to add a regex string directly to the object.
/// ```
/// let regex_string = human_regex::nonescaped_text(r"^\d{2}$");
/// println!("{}", regex_string.to_string());
/// assert!(regex_string.to_regex().is_match("21"));
/// assert!(!regex_string.to_regex().is_match("007"));
/// ```