So I am trying to write a regular expression that will match a defined string and then eventually another word. For example in the string SELECT * FROM persons ORDER BY name ASC LIMIT 10
I would like to match ORDER BY name ASC LIMIT
. It seems like it should be simple but I haven't been able to figure it out.
Essentially I don't care whats between the ORDER BY and the LIMIT but I'd like to stop matching at the LIMIT. Here is what I have so far:
string pattern = @"\s*ORDER\s*BY.*LIMIT";
But it ends up matching the entire SELECT statement and I want to stop at the LIMIT.
Thanks in advance!