// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r#"(?m)\n(?=[^"]+?"\s*$)"#).unwrap();
let string = "ability,n. 能力,能耐;才能
able,adj. 能; 有能力的;能干的
about,\"prep. 关于;大约
n. 大致;粗枝大叶;不拘小节的人
adj. 在附近的;四处走动的;在起作用的
adv. 大约;周围;到处\"
above,\"prep. 超过;在……上面;在……之上
n. 上文
adj. 上文的
adv. 在上面;在上文\"
accident,n. 事故;意外; 意外事件;机遇
accurate,adj. 精确的
ache,\"n. 疼痛
vi. 疼痛;渴望\"
activity,n. 活动;行动;活跃
actor,n. 男演员;行动者;作用物
actress,n. 女演员
actually,adv. 实际上;事实上";
let substitution = " ";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Rust, please visit: https://docs.rs/regex/latest/regex/