-1

I have a list containing text data from a docx file. How can I apply some regex or some lambda function to go through this whole list and 'clean it'; meaning, I'd like to take out \t and \n

['\tSA   [WP5]\t\t\n', "<class 'docx.text.paragraph.Paragraph'>\n", '\t\tCOUNTRY:\n', "<class 'docx.text.paragraph.Paragraph'>\n", '\n']

so that my output looks like:

['SA   [WP5]', "<class 'docx.text.paragraph.Paragraph'>", 'COUNTRY:', "<class 'docx.text.paragraph.Paragraph'>", '']
Wiktor Stribiżew
  • 561,645
  • 34
  • 376
  • 476
sgerbhctim
  • 2,898
  • 6
  • 31
  • 52

1 Answers1

1
[x.replace('\t', '').replace('\n', '') for  x in lst] 

would do it, without the need for regex.

jez
  • 13,939
  • 3
  • 32
  • 59