I m trying to remove a ‘ and a , from Python regexp
I came up with:
regex = re.compile("[^']*.dbf[^,]*")
file_handle = open(file)
for line in file_handle:
m = regex.match(line)
if m:
print m.group()
So that I would have the following matching string
/u01/app/data/ORCL/system01.dbf
instead of
[blank spaces]'/u01/app/data/ORCL/system01.dbf',
Thanks in advance.
Advertisement
Answer
regex = re.compile(r"[^'](*.dbf)'?[^,]*")
i think you missed the matching ‘, and the result should be m.group(1)
should be:
regex = re.compile(r"([^']*.dbf)'?[^,]*")