[][src]Function fungus::sys::extract_strings

pub fn extract_strings<T: AsRef<Path>>(
    path: T,
    rx: &Regex
) -> FuResult<Vec<String>>

Returns the captured strings from the given regular expression rx.

Examples

use fungus::prelude::*;

let tmpdir = PathBuf::from("tests/temp").abs().unwrap().mash("file_doc_extract_strings");
assert!(sys::remove_all(&tmpdir).is_ok());
let tmpfile = tmpdir.mash("file1");
assert!(sys::mkdir(&tmpdir).is_ok());
let rx = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap();
assert!(sys::write(&tmpfile, "Not my favorite movie: 'Citizen Kane' (1941).").is_ok());
assert_eq!(sys::extract_strings(&tmpfile, &rx).unwrap(), vec!["Citizen Kane", "1941"]);
assert!(sys::remove_all(&tmpdir).is_ok());