using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"([\S]*)[\s]+([\S]*[\s]+[\S]*)[\s]+([0-9]{1,2})\%";
string input = @"RY4 Asian Flavor 10-15%
RY4 Double Flavor 5%-15%
Smooth Flavor 2 drops per 5 ml
Spearmint Flavor <5% Very Strong
Strawberries and Cream Flavor 10-12%
Strawberry Flavor 3%-15%
Strawberry Kiwi 20% 1/5
Strawberry Ripe 15%
Sweet Cream Flavor 5-10% 4/5 recommended for combining fake butter taste
Sweet Tart: 10% 5/5 Tastes more like Smarties
Sweetener 2%-6%
Tangerine Flavor (oil based) 1-5% 5/5
Tiramisu Flavor 2-5% VERY strong
Toasted Almond Flavor 15%";
RegexOptions options = RegexOptions.IgnoreCase;
Match m = Regex.Match(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