I tried looking for an answer to this question but just couldn't finding anything and I hope that there's an easy solution for this. I have and using the following code in C#,
String pattern = ("(hello|hello world)"); Regex regex = new Regex(pattern, RegexOptions.IgnoreCase); var matches = regex.Matches("hello world"); Question is, is there a way for the matches method to return the longest pattern first? In this case, I want to get "hello world" as my match as opposed to just "hello". This is just an example but my pattern list consist of decent amount of words in it.
Regexrather than, say, aDictionary?