Jul-01-2019, 02:40 AM
Hi, I'm building a python script which put an underline on a matched string on my regex pattern. Issue is when migrated to 2.6 I'm getting the below traceback. What would be the correct way to build this correctly?
finalout = re.sub(r'>.*(?=.*)', lambda m: '\x1b[4m{}\x1b[0m'.format(m.group()),compout) print finalout
Error:Traceback (most recent call last):
File "compcon.py", line 313, in <module>
main()
File "compcon.py", line 302, in main
finalout = re.sub(r'>.*(?=.*)', lambda m: '\x1b[4m{}\x1b[0m'.format(m.group()),compout)
File "/usr/lib64/python2.6/re.py", line 151, in sub
return _compile(pattern, 0).sub(repl, string, count)
File "compcon.py", line 302, in <lambda>
finalout = re.sub(r'>.*(?=.*)', lambda m: '\x1b[4m{}\x1b[0m'.format(m.group()),compout)
ValueError: zero length field name in format