// 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"(?mi)(?:©(?:\s*Copyright)?|Copyright(?:\s*©)?)\s*\d+(?:\s*-\s*\d+)?\s*(.*?(?=\W*All\s+rights\s+reserved)|[^.\n]*(?=\.)|.*)").unwrap();
let string = "Copyright © 2019 Apple Inc All rights reserved.
© 2019 Quid, Inc. All Rights Reserved.
© 2009 Database Designs
© 2019 Rediker Software, All Rights Reserved
©2019 EVOSUS, INC. ALL RIGHTS RESERVED
© 2019 Walmart. All Rights Reserved.
© Copyright 2003-2019 Exxon Mobil Corporation. All Rights Reserved.
Copyright © 1978-2019 Berkshire Hathaway Inc.
© 2019 McKesson Corporation
© 2019 UnitedHealth Group. All rights reserved.
© Copyright 1999 - 2019 CVS Health
Copyright 2019 General Motors. All Rights Reserved.
© 2019 Ford Motor Company
©2019 AT&T Intellectual Property. All rights reserved.
© 2019 GENERAL ELECTRIC
Copyright ©2019 AmerisourceBergen Corporation. All Rights Reserved.
© 2019 Verizon
© 2019 Fannie Mae
Copyright © 2018 Jonas Construction Software Inc. All rights reserved.
All Comments © Copyright 2017 Kroger | The Kroger Co. All Rights Reserved
© 2019 Express Scripts Holding Company. All Rights Reserved. 1 Express Way, St. Louis, MO 63121
© 2019 JPMorgan Chase & Co.
Copyright © 1995 - 2018 Boeing. All Rights Reserved.
© 2019 Bank of America Corporation. All rights reserved.
© 1999 - 2019 Wells Fargo. All rights reserved. NMLSR ID 399801
©2019 Cardinal Health. All rights reserved.
© 2019 Quid, Inc All Rights Reserved.";
// 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/