[−][src]Function fungus::sys::extract_string_p
pub fn extract_string_p<T: AsRef<Path>, U: AsRef<str>>(
path: T,
rx: U
) -> FuResult<String>
Returns the first captured string from the given regular expression rx
.
Examples
use fungus::prelude::*; let tmpdir = PathBuf::from("tests/temp").abs().unwrap().mash("file_doc_extract_string_p"); 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_string(&tmpfile, &rx).unwrap(), "Citizen Kane"); assert!(sys::remove_all(&tmpdir).is_ok());