1.代码
rust
use std::fs::File;
use std::io::{BufRead, BufReader};
use regex::{Regex};
fn main() {
let f = File::open("F:\\0-X-RUST\\1-systematic\\ch2-fileRead\\data\\test.csv").unwrap();
let mut reader = BufReader::new(f);
let re = Regex::new("45asd").unwrap();
for line in reader.lines(){
let line = line.unwrap();
println!("{}", line);
let c_s = re.find(&*line);
match c_s {
None => {println!("未匹配到:45asd")}
Some(_) => { print!("包含{:?}", c_s)}
}
}
}
2.运行结果
3.工程源码含数据文件
下载地址:https://download.csdn.net/download/qq_34321590/89612367