I'm looking to extract the value of a particular variable in a text file that I'm parsing containing code. The variable name changes, as does its position in the code, but I know the pattern therefore I successfully obtain its value and store it in a variable, called myVar.
To get the value, i.e. the string between quotes after the myVar and equals sign, i.e. myVar = "value i want is here" I thought about using regex as follows:
Pattern q = Pattern.compile(myVar + "\= \"(.*)\"" );
But I get an error when compiling:
error: illegal escape character Pattern q = Pattern.compile(myVar + "\= \"(.*)\"" );
Is this something to do with concatenating the myVar string with the regular expression?
myVarat runtime?variable_name[2]