It will be difficult to integrate the secondary portion like you mentioned. Continue using the regular expression technique for the first part like you did. Using the java.util.regex.Pattern and java.util.regex.Matcher you can determine determine if there is a match by using the find() method (on each of the keywords). If true, you can call the start() method to determine the position of the keyword in the last call to the find method. (Use these methods in tandem).
The tricky part is in actuality very easy using the String class is to determine of all the instances of a '"' double quote character and obtaining their character positions. Next figure out if the start of the keyword position is greater than the position of the first double quote and less than the position of the next double quote character. First you need to ensure that one double quote the sibling of it's respective double quote pair. Of course you may want to ensure that the entire keyword falls in between both these positions. Furthermore you'll need to be smart about double quotes falling on separate lines or continuation lines if that scenario applies.
Basically don't try to apply the secondary portion using regex expressions is my suggestion unless you really want to go crazy trying to implement it.