This is a very basic regex question.
Suppose I have lots of string constants throughout my code (enclosed with double quotations). Some of these strings contain class substring like the "declassification"
constant in this example:
public class Names {
string text = "declassification";
string classified = "foo";
}
All 3 lines contain class, but only "declassification"
is interesting to me because it's between double quotations.
What I did:
I found this question: Regex.Matches c# double quotes. It tells me how to get everything in a double quotations like this: \"(.*?)\"
. But I need to search for a specific string anywhere between the double quotations.
This question: Extract the values between the double quotes using regex also tells me to use this: @"""New[^"":]+:[^""]+"""
which doesn't work for me.
Find Results:
Wrong:
public class Names {
string text = "declassification";
string classified = "foo";
Expected:
string text = "declassification";
Question:
When I search with Visual Studio Find Tool, how can I only search through the string constants and ignore the rest of the files?