Remove bash formatting in text using python -
I am getting a text file with data from the bass output, so it has formatted data, more specifically, The codes are:
[0; 31m16521 [0; 0m [0; Data-Economy PDF for 32 Modscape / Business-Models [0; 0 M I want to strip the form, that is, get it in plain text:
16521 For desktop / business-models- Data-economy.pdf Unless I understand that it starts with [[/ />, ; and m , I want to know what is a clear and more correct way of doing this.
You can do this with a regex:
import re s = '[0; 31m16521 [0; 0m [0; 32 Data-Economy for MSc Desktop / Business-Models Pdf [0; 0m 'new_s = re.sub (r' \ [. *?;. *? M ',' ', s)) & Gt; & Gt; Data-economy pdf for printed new_s 16521 desktop / business model
Comments
Post a Comment