I am trying to get everything between /*
and */
I am using re
library and following expression to get data
pattern = re.compile(r'(?<=\/\*)(.|\n)+?(?=\*\/)')
result = pattern.findall(query)
query - a string with data shown in the image (may contain line breaks, etc.)
my expression is not working correctly and I get this result
['\n', '\n', '\n', '\n']
how can I get all content in between /*
and */
?
re.DOTALL
to make .
match newlines(?:<expr>)
>>> txt = """
/*
name = foo
table = bar
*/ don't capture this
"""
>>> re.findall(r'(?:/\*)(.*?)(?:\*/)', txt, re.DOTALL)
['\nname: foo\ntable: bar\n']