我正在试图找出一个正则表达式来验证其中一个(<,>,=,!=)以确保它是整数或单引号字符串(可能带空格)
一些例子:
SELECT * WHERE field1=5 // OK
SELECT * WHERE field1= 5 // OK
SELECT * WHERE field1< -2 // OK
SELECT * WHERE field1='5' // OK
SELECT * WHERE field1=a // NOT OK - a is not an integer
SELECT * WHERE field1!='a' // OK
SELECT * WHERE field1='a // NOT OK - missing closing quote
EDIT: I forgot to add it should work with multiple fields such as
SELECT * WHERE field1=5 AND field2=b // NOT OK since field2 following is not a int
SELECT * WHERE field1=5 AND (field1<6 AND fieldb='a') // OK