Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
(["'])\s*(SELECT)(?:\s+.*)?\s+(FROM)(?:\s+.*)?\1(?:[^\w]|$)
/
gm
Input 1
1
New
SELECT * FROM tbl -- no match - not in a string "SELECT * FROM tbl" -- matches - in a double-quoted string 'SELECT * FROM tbl;' -- matches - in a single-quoted string 'SELECT * FROM it's -- no match - letter after end quote "SELECT * FROM tbl' -- no match - quotation marks don't match 'SELECT * FROM tbl" -- no match - quotation marks don't match "select * from tbl" -- no match - keywords not upper case 'Select * From tbl' -- no match - still not all upper case "SELECT col1 FROM" -- matches - even though no table name ' SELECT col1 FROM ' -- matches - as above with more whitespace 'SELECT col1, col2 FROM' -- matches - with multiple columns