pragmatic-segmenter 0.1.3

Rust port of pySBD v3.1.0.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use onig::{Error, Regex, RegexOptions, Syntax};

pub struct Rule(Regex, &'static str);

impl Rule {
    pub fn new(regex: &str, replace: &'static str) -> Result<Self, Error> {
        Ok(Rule(
            Regex::with_options(regex, RegexOptions::REGEX_OPTION_NONE, Syntax::ruby())?,
            replace,
        ))
    }

    #[must_use]
    pub fn replace_all(&self, text: &str) -> String {
        self.0.replace_all(text, self.1)
    }
}