Skip to content

Commit c59d4da

Browse files
committed
add boundary strings
1 parent 6bedb42 commit c59d4da

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/rust/src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ use extendr_api::prelude::*;
66
extendr_module! {
77
mod stringer;
88

9+
fn get_boundary_character;
10+
fn get_boundary_linebreak;
11+
fn get_boundary_sentence;
12+
fn get_boundary_word;
13+
914
fn add_s_flag_to_dot;
1015
fn add_m_flag_to;
1116
fn add_x_flag_to;
@@ -23,6 +28,26 @@ extendr_module! {
2328
fn str_bytes_locates;
2429
}
2530

31+
#[extendr]
32+
pub fn get_boundary_character() -> String {
33+
"^\\w(?s:.)+\\w$".to_string()
34+
}
35+
36+
#[extendr]
37+
pub fn get_boundary_word() -> String {
38+
"^\\b(?s:.)+\\b$".to_string()
39+
}
40+
41+
#[extendr]
42+
pub fn get_boundary_linebreak() -> String {
43+
"^(\\n|\\r|\\r\\n)(?s:.)+(\\n|\\r|\\r\\n)$".to_string()
44+
}
45+
46+
#[extendr]
47+
pub fn get_boundary_sentence() -> String {
48+
"^(\\b|\\s|\"|!|\\?|,|\\.|'|:|،|-|—|`|\\|)+(?s:.)*(\\b|\\s|\"|!|\\?|,|\\.|'|:|،|-|—|`|\\|)+$".to_string()
49+
}
50+
2651
#[extendr]
2752
pub fn add_s_flag_to_dot(string: String) -> String {
2853
string.replace(".", "(?s:.)")

0 commit comments

Comments
 (0)