I have a lot of source codes with SQL queries like below:
c_query := "SELECT * FROM TABLE WHERE FIELD_NAME_ONE[2] = 'AB' AND FIELD_NAME_TWO[1,8] = 'ABCDEFGH'"
I would like to match these: FIELD_NAME_ONE[2] and FIELD_NAME_TWO[1,8] and these patterns must be found between double quotes (").
Edit
c_query := “SELECT * FROM TABLE WHERE FIELD_NAME_ONE[2] = ‘AB’ AND FIELD_NAME_TWO[1,8] = ‘ABCDEFGH’ AND TESTE[9] = ‘XXXXXXXXX’ AND FOO = ‘” + is_an_array[2] + “‘”
It shouldn´t match is_an_array[2] because is not inside the double quotes.
I’m assuming you want to be able to match more than just those two specific fields, otherwise you wouldn’t have gone to the trouble of applying regular expressions:
This will find any sequence of letters, numbers and underscores followed by square brackets, with 1 or more comma-separated numbers.
If you only want to match a sequence of letters and underscores before the square brackets, ammend the pattern to: