// 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)SRR([0-9]+)([\.])([0-9]+)([\s]+)([A-Z]+)").unwrap();
let string = " sequence_id cdr3_aa
0 SRR11610498.829751 AKDLGPDAGYTVFNDYFDN
1 SRR11610498.853725 AKDLGPDAGYTVFNDYFDN
2 SRR11610498.856922 AKDLGPDAGYTVFNHYFDN
3 SRR11610498.861591 AKDLGPDAGYTVFNDYFDN
4 SRR11610498.909314 AKDLGPDAGYTVFNDYFDN
5 SRR11610498.915768 AKDLGPDAGYTVFNDYFDN
6 SRR11610498.922245 ARGGLVVVDSFDY
7 SRR11610498.1017490 ASDLSYASSWLHYFDV
8 SRR11610498.1022079 ARLRFDNGALYFDY
9 SRR11610498.1037667 ASSAPPSGFNWFDP
10 SRR11610498.1111232 AKGPQIVATTTDNLEV
11 SRR11610498.1183596 AKDLGPDAGYTVFNDYFDN
";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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/