Suppose the folowing SQL command:
update [TABLE] set [value] = 'UserName' where key1 = :param1 and key2 = :param2
I would like to extract :param1
and :param2
from the SQL. So, I´m using the following regex to match the SQL String:
:([\w.$]+|"[^"]+"|'[^']+')
This is working fine, except when the SQL String contains a colon (:) between quotes (") or single quotes (').
Eg, I would like that the regex matcher returns me only :param1
and :param2
to the following queries as well:
update [TABLE] set [value] = ':UserName' where key1 = :param1 and key2 = :param2
update [TABLE] set [value] = 'User=:UserName' where key1 = :param1 and key2 = :param2
update [TABLE] set [value] = '2015-04-26 21:59:24' where key1 = :param1 and key2 = :param2
because the values :UserName, User=:UserName and 2015-04-26 21:59:24 are between Single Quotes...
I tried to modify the regex expression, but nothing seems to work. What should I do?