How to create a Custom Pattern to search for few keywords within a string in code

Hi,
I am using the Code Inspection --> Custom Patterns to search for a particular word within hardcoded strings in the C# code.

Example if the code is:
string sqlQuery = "SELECT * FROM TABLE1 where ID in (" + selectedIds + ")";

In the above line of code, I want to search all hardcoded SQL strings in code which use a sql "IN" clause is used and contents of the IN clause are concatenated using a string C# variable.

Now if I just use the Visual Studio "Find in Files" option using the string as "IN (" "; then I am able to find all such instances in code. But I want to also create a resharper rule to find all such line numbers in code.

So I tried various options in Custom Pattern, but none of them works.
Example: " $idt2$ IN (" + $datavar$ + ") $idt3$ ";
In the above pattern idt1, idt2 and datavar are all identifiers

Please help in finding how to write a correct resharper search pattern for this.

Thanks and Regards,
Chetna

Please sign in to leave a comment.