How would I match the string:
log("Hello World")
log("This is second")
What I am doing is I am getting the data from a separate file that has multiple lines.
I want to match every string with a regex that has log()
in python 3.
How would I match the string:
log("Hello World")
log("This is second")
What I am doing is I am getting the data from a separate file that has multiple lines.
I want to match every string with a regex that has log()
in python 3.
So far we have tried:
import re # import regular expresisons
import math # integers with expressions
def readFile(filename):
data = open(filename, "r+").read()
return str(data)
def main():
code = readFile(input('Select file: '))
pattern2 = re.findall("log(([^)]+))", code)
# pattern = re.findall("log\a(\z)", code)
for pattern in pattern2:
print(pattern[0])