// 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)(?<=P ).*").unwrap();
let string = "List Bill Number: 91612223 Remit To:
List Bill Date: September 28, 2020 P.O. Box 9121
Minneapolis, MN 55480-9121
Bill-to:
C8144459
ATTN: ACCOUNTS PAYABLE XYZ Worldwide, Inc. and
ABCUC Subsidiaries
DONORE
DROG
qwefghj List Bill Invoice Total: USD 2,127.84
List Bill Invoice Balance: USD 2,127.84
Payment Due: October 10, 2020
List Bill
Group: C8144459
Load # Invoice Number Invoice Total Invoice Balance
333311392 6124765056 USD 447.74 USD 447.74
Type Location Name City/State/Zip BOL Actv Date # PCS Stop Ref. Number
P Barrett Distribution Centers Somerset, NJ 08873 5027905 09/08/2020 290 CAS 5027905
D 102- Wegmans GMDC ROCHESTER, NY 14623 09/15/2020
Load # Invoice Number Invoice Total Invoice Balance
333698986 6124960145 USD 358.78 USD 358.78
Type Location Name City/State/Zip BOL Actv Date # PCS Stop Ref. Number
P Barrett Distribution Centers - Memphis, TN 38141 5028124 09/09/2020 48 PLT 5028124
Memphis
D Walgreens Moreno Valley, Moreno Valley, CA 92551 09/17/2020
Load # Invoice Number Invoice Total Invoice Balance
333803610 6125029363 USD 347.78 USD 347.78
Type Location Name City/State/Zip BOL Actv Date # PCS Stop Ref. Number
P Barrett Distribution Centers - Memphis, TN 38141 5028208 09/10/2020 12 CAS 5028208
Memphis
D NATIONAL ECZEMA Novato, CA 94945 09/18/2020
ASSOCIATION
Load # Invoice Number Invoice Total Invoice Balance
334236950 6125032211 USD 567.88 USD 567.88
Type Location Name City/State/Zip BOL Actv Date # PCS Stop Ref. Number
P Barrett Distribution Centers Somerset, NJ 08873 5028225 09/16/2020 230 CAS 5028225
D C AND S WHOLESALE Bethlehem, PA 18020 09/18/2020
Page 1 of 3List Bill Number: 91612223 Remit To:
List Bill Date: September 28, 2020 P.O. Box 9121
Minneapolis, MN 55480-9121
Bill-to:
C8144459
ATTN: ACCOUNTS PAYABLE XYZ Worldwide, Inc. and
ABCUC Subsidiaries
DONORE ROAD INDUSTRIAL ESTATE
DR
IRELAND List Bill Invoice Total: USD 2,127.84
List Bill Invoice Balance: USD 2,127.84
Payment Due: October 10, 2020
List Bill
Group: C8144459
Load # Invoice Number Invoice Total Invoice Balance
334365135 6125220068 USD 187.78 USD 187.78
Type Location Name City/State/Zip BOL Actv Date # PCS Stop Ref. Number
P Barrett Distribution Centers - Memphis, TN 38141 5028451 09/16/2020 16 CAS 5028451
Memphis
D WALGREENS 075044 WILLIAMSTON, SC 29697 09/23/2020
Load # Invoice Number Invoice Total Invoice Balance
333285686 6125333531 USD 217.88 USD 217.88
Type Location Name City/State/Zip BOL Actv Date # PCS Stop Ref. Number
P Barrett Distribution Centers - Memphis, TN 38141 5027871 09/03/2020 29 CAS 5027871
Memphis
D WALGREENS-WINDSOR Windsor, WI 53598 09/11/2020
Group Total: # of Invoices Invoice Total Invoice Balance
C8144459 6 USD 2,127.84 USD 2,127.84
Page 2 of 3List Bill Number: 91612223 Remit To:
List Bill Date: September 28, 2020 P.O. Box 9121
Minneapolis, MN 55480-9121
Bill-to:
C8144459
ATTN: ACCOUNTS PAYABLE XYZ Worldwide, Inc. and
ABCUC Subsidiaries
DONORE ROAD INDUSTRIAL ESTATE
ab
asdfghj List Bill Invoice Total: USD 2,127.84
List Bill Invoice Balance: USD 2,127.84
Payment Due: October 10, 2020
List Bill
Grand Totals for Customer # of Invoices Charges Accessorials Adjustments Invoice Total Payments Invoice Balance
6 USD 1,634.89 USD 492.95 USD 0.00 USD 2,127.84 USD 0.00 USD 2,127.84
XYZ wants to ensure your payment is applied to your account as intended.
Please reference the List Bill number on your payment. If there is a payment amount difference on this List Bill, please
provide detail including the individual invoice numbers provide and the reason of the payment discrepancy.
Thank You.
XYZ Company, Inc., 14800 Ch, Suite 1500, Eden Prairie, MN 55347
Fed Tax ID 12-1234567, DNB 1234567, MC 12344
Page 3 of 3";
// 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/