This maintains a flexible distance between commas, etc. The raw regular expression should look like this:
^Select\s+(?:\w+\s*(?:(?=from\b)|,\s*))+from\s+\w+\s+where\s+\w+\s*=\s*'[^']*'$
You will need to avoid any platform-specific characters (for example, in C #, it \sshould be \\s.) In C #, it will look like this:@"^Select\s+(?:\w+\s*(?:(?=from\b)|,\s*))+from\s+\w+\s+where\s+\w+\s*=\s*'[^']*'$"
Also, be sure to make your expression ignore the case. In the end it can javascript on /iin the following way: /select ...+/i.
source
share