I need to extract a substring from a given string using regex.
I am parsing c# code, and I need to get the variable which is checked for null value.
Note: I save the c# code in a text file and read the lines as string value
My string could be in following format.
string code = "if (!(strOld_Value == "" && strNew_Value == "") || (strOld_Value == "" && strNew_Value.ToLower() != "") ";
From the above input string, I need to extarct the variable names, that are checked for null values. i.e) my desired output should be
strOld_Value == ""
strNew_Value == ""
strOld_Value == ""
strNew_Value.ToLower() != ""
It is not necessary that my string will always in the same pattern, sometimes my string can be a simple one as follows,
string code = "if (Name == "")"
In the above case, my desired output is,
Name == ""
Is it possible to write a generic regex pattern for this scenario? Thanks in Advance.