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
use Regex;
/// Split the input string into an array of its words.
///
/// If the regex for filtering purposes is not provided, we will take only groups of normal letters as words by default.
///
/// # Arguments
///
/// * `s` - The input string to split into words.
/// * `re` - Optional regex for word filtering. If provided, only matching substrings are considered words.
///
/// # Returns
///
/// Returns a vector containing the words extracted from the input string.
/// If the input string is empty or None, returns an empty vector.
///
/// # Example
///
/// ```rust
/// use lorust::words;
///
/// let s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.".to_string();
/// let words = words(s, None);
/// assert_eq!(words, vec!["Lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit"]);
/// ```