lua-patterns/examples/strings.rs
2017-04-18 19:20:24 +02:00

20 lines
502 B
Rust

extern crate lua_patterns;
use lua_patterns::LuaPattern;
use std::env;
use std::fs::File;
use std::io::prelude::*;
fn main() {
let file = env::args().skip(1).next().expect("provide a binary file");
let mut f = File::open(&file).expect("can't open file");
let mut buf = Vec::new();
f.read_to_end(&mut buf).expect("can't read file");
let mut words = LuaPattern::new("%a%a+");
for w in words.gmatch_bytes(&buf) {
println!("{}",std::str::from_utf8(w).unwrap());
}
}