I've a txt file with a list of variables like this:
$VARIABLE1 = 'VALUE1';
$VARIABLE2 = 'VALUE2';
$VARIABLE3 = 'VALUE3';
$VARIABLE4 = 'VALUE4';
I'd like to exctract only the value of the variable I want find using javascript (example: find value of $VARIABLE3 => VALUE3). Someone can help?
In Python I found a way using a function like this:
def findValue():
import re
valueToFind = []
lineNum = 0
pattern = re.compile("string to find", re.IGNORECASE)
with open(FILE_PATH, 'rt') as myFile:
for line in myFile:
lineNum += 1
if pattern.search(line) is not None:
valueToFind.append((lineNum, line.rstrip('\n')))
for find in valueToFind:
string = find[1].split("'")
return string[1]
Thanks in advance.