easy_regex/
metacharacters.rs1use crate::{settings::Settings, EasyRegex};
4
5impl EasyRegex {
6 pub fn only_the_beginning() -> Self {
8 EasyRegex("\\A".to_string())
9 }
10
11 pub fn word_boundary(self) -> Self {
13 let result = format!("{}\\b", self.0);
14 EasyRegex(result)
15 }
16
17 pub fn word(self, settings: &Settings) -> Self {
19 let result = self.literal("\\w", settings);
20 result
21 }
22
23 pub fn non_word(self, settings: &Settings) -> Self {
25 let result = self.literal("\\W", settings);
26 result
27 }
28
29 pub fn digit(self, settings: &Settings) -> Self {
31 let result = self.literal("\\d", settings);
32 result
33 }
34
35 pub fn non_digit(self, settings: &Settings) -> Self {
37 let result = self.literal("\\D", settings);
38 result
39 }
40
41 pub fn whitespace(self, settings: &Settings) -> Self {
43 let result = self.literal("\\s", settings);
44 result
45 }
46
47 pub fn non_whitespace(self, settings: &Settings) -> Self {
49 let result = self.literal("\\S", settings);
50 result
51 }
52
53 pub fn non_word_boundary(self) -> Self {
55 let result = format!("{}\\B", self.0);
56 EasyRegex(result)
57 }
58
59 pub fn only_the_end(self) -> Self {
61 let result = format!("{}\\z", self.0);
62 EasyRegex(result)
63 }
64}