I need to match a string under the following conditions using Regex in C#:
Entire string can only be alphanumeric (including spaces). Example string should only match are: ( numerical values can change)
Example1 String: best 5 products
Example2 String: 5 best products
Example3 String: products 5 best
I am looking to get get "5 best" or "best 5" but the following strings are also matching:
Example1 String: best anything 5 products
Example2 String: 5 anything best products
Example3 String: products 5 anything best
I am using:
string utter11 = Console.ReadLine();
string pattern11 = "^(?=.*best)(?=.*[0-9]).*$";
bool match = Regex.IsMatch(utter11, pattern11, RegexOptions.IgnoreCase);
Console.WriteLine(match);
Any suggestions are welcome. Thanks