// 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"OTHER REFERENCE:\s\d{8}\D{4}\s(?!\b(SHOPIFY)\b)\w+").unwrap();
let string = "OTHER REFERENCE: 20180201AIEJ SHOPIFY INTERNATIO SHOPIFY PMT AMT GBP 664367.38 |
OTHER REFERENCE: 20180201AJJS Shopify (Ireland) Limited SEPA Credit PMT AMT EUR 22718.08 |
OTHER REFERENCE: 20180301AIOV SHOPIFY INTERNATIO PMT AMT GBP 692673.45 |
OTHER REFERENCE: 20180302AKIH Shopify (Ireland) Limited SEPA Credit PMT AMT EUR 20147.37 |
OTHER REFERENCE: 20180226AJYS STRIPE DDA BACS PMT AMT GBP 122328.84 |
OTHER REFERENCE: 20180125AJDH STRIPE DDA BACS PMT AMT GBP 48392.41 |
OTHER REFERENCE: 20180103AGEJ STRIPE DDA BACS PMT AMT GBP 106257.89 | OTHER REFERENCE: 20180327AIQU STRIPE DDA BACS PMT AMT GBP 83725.34 |
(?m)^(?:(?!\\bSHOPIFY\\b).)+$";
// 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/