How can i use regex in python to detect in one file only the stings between the brackets? So If i have some text like this:
</seg>
<src>Sono stati riportati casi di (sgomberi forzati) e violazioni dei diritti umani da parte della polizia, ma su scala minore rispetto agli anni precedenti.</src>
and I want to detect only (sgomberi forzati)
I use the
for line in file.readlines():
m=re.compile('\((.*?)\)', re.DOTALL).findall(line)
print m
but it does not print what I need: it prints also brackets empty like this
[]
[u'sgomberi forzati']
returnstatement anywhere in your code. If you mean "It doesn't print what I need": it works for me. Unless you want it to print something other than['regional economies', 'transportation']? Please describe what kind of output you expect.