Highlight/Underline a string | ValueError: zero length field name in format - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Highlight/Underline a string | ValueError: zero length field name in format (/thread-19467.html) |
Highlight/Underline a string | ValueError: zero length field name in format - searching1 - Jul-01-2019 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
RE: Highlight/Underline a string | ValueError: zero length field name in format - metulburr - Jul-01-2019 In python2.6 and earlier you need indices in the format specs try: '\x1b[4m{0}\x1b[0m'.format(m.group()) |