using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<!\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)";
string input = @"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";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx