Function lodust::words[][src]

pub fn words(s: String, re: Option<Regex>) -> Vec<String>
Expand description

(String) Split the input string into array of its words.

If the regex for filtering purpose is not provided, we will take only group of normal letters as word by default.

Example

use lodust::words;
use regex::Regex;

let word = words("fred, barney, & pebbles".to_string(), None);
// => ['fred', 'barney', 'pebbles']

let word = words("fred, barney, & pebbles".to_string(), Some(Regex::new("[^, ]+").unwrap()));
// => ['fred', 'barney', '&', 'pebbles']