// 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)(?<!\d|-|\/|to|\$)(?<!\$(\d)\.)([1-9][0-9]{0,2}(\.\d{0,2})?\s?)(lbs|lb|LBS|LB|KG|kg|G|g|L|l+)(?!\d|\w)").unwrap();
let string = "10lb Potato bag
Apples Gld Delicious 3lb
Grandfer Rocha Pear2.5lbs
CHIN.MAND.5LB
Batata Veg (10LB)
SIG 170LB99 Legging SzB 1ea
ARJO CDA1450035 SupBlk 400LB1ea
AHC EB205L
DRI 10220-1 Bariatric500lb 1 ea
TILDA SONA MASOORI 20 LBS
OVAL ROASTER 9 - 12 LBS
ORGANIC TRIPACK FRUIT 1.2 KG
KGF5KT2404 PEPLUM T, PURPLE
AIR 1773LB-XL 15-20 KnXL 1ea
PLUM BAG 1KG US
NEXT XTRA 100G
SUDOCREM 60G
EGGPLANT GRILLED IN OIL (3KG)
CORONATION GRAPE 2L CA
MEAT DEAL $11.00 KG
LIVE LOBSTER- 2.00-3.00 LB-MSC
PC MAGIC GROW 20-20-20 3.55KG
KGF7W3409 KGVELCROWB,GREY
TZATZIKI 500G
2+1 LEAD MIX";
// 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/