I want to sub designated string for text content .like python model re.sub or replace.
or how to delete designated string.
text:
This small script is intended to allow conversion from HTML markup to
code:
extern crate regex;
use regex::Regex;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
fn main() {
let path = Path::new("G:\\workspace\\test.txt");
let display = path.display();
let mut file = match File::open(&path) {
Err(why) => panic!("couldn't open {}: {}", display,why.description()),
Ok(file) => file,
};
let mut s = String::new();
match file.read_to_string(&mut s) {
Err(why) => panic!("couldn't read {}: {}", display,why.description()),
Ok(_) => print!("successful\n"),
}
let re_match= Regex::new(r"(small)").unwrap();
let search_result=re_match.captures(&s).unwrap();
println!("{} do",search_result.get(1).unwrap().as_str());
}