I want to capture the java variable name in java file using regex. i am able to achieve one level where variable is assigned something , but if variable is not assigned anything then how to get it ?
My Regex : (\w*)<?>?\s*=(?=(?:[^"]|"[^"]*["])*$)
Click here for sample
it should included both variable but not import class;
import java.io.File;
import java.io.IOException ;
String test="test";
String test22;
String includeThisAlso ;
it should match the variable but not import class.
^\s*(?:List\s*<)?\w+>?\s*\K\w+(?=\s*=|\s*;)^\s*(?:\w*\s*<)?\w+>?\s*\K\w+(?=\s*=|\s*;)but can you please explain the regex also , what is the \Kprivate final String COMMENTS = "test";