fune/third_party/rust/regex/examples/shootout-regex-dna-replace.rs
Chris H-C 072d3a741d Bug 1596132 - mach vendor rust for glean-preview r=janerik,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D54616

--HG--
rename : third_party/rust/itoa/LICENSE-MIT => third_party/rust/ffi-support/LICENSE-MIT
rename : third_party/rust/regex/src/literal/mod.rs => third_party/rust/regex/src/literal/imp.rs
rename : third_party/rust/ryu/benchmark/benchmark.rs => third_party/rust/ryu/examples/upstream_benchmark.rs
rename : third_party/rust/ryu/src/mulshift128.rs => third_party/rust/ryu/src/d2s_intrinsics.rs
extra : moz-landing-system : lando
2019-12-09 15:01:10 +00:00

19 lines
483 B
Rust

extern crate regex;
use std::io::{self, Read};
macro_rules! regex {
($re:expr) => {{
use regex::internal::ExecBuilder;
ExecBuilder::new($re).build().unwrap().into_regex()
}};
}
fn main() {
let mut seq = String::with_capacity(50 * (1 << 20));
io::stdin().read_to_string(&mut seq).unwrap();
let ilen = seq.len();
seq = regex!(">[^\n]*\n|\n").replace_all(&seq, "").into_owned();
println!("original: {}, replaced: {}", ilen, seq.len());
}