обработка текста в python для удаления шестнадцатеричных цветовых кодов из строки - PullRequest
0 голосов
/ 23 апреля 2020

У меня есть pandas фрейм данных со столбцом текста, и я хочу удалить оттуда цветовые коды html, вот пример текста:

{color:#000000}So today while lurking around with the processing, I have stumbled across the main reason why it takes 15 minutes. {color}{color:#000000} {color}{color:#000000}It is because our trigger tooks 15 minutes to finishing sending the signal!{color}{color:#000000} {color}{color:#000000}

Мой желаемый вывод не имеют эти шестнадцатеричные цвета

So today while lurking around with the processing, I have stumbled across the main reason why it takes 15 minutes.It is because our trigger tooks 15 minutes to finishing sending the signal

1 Ответ

2 голосов
/ 23 апреля 2020

Попробуйте:

re.sub(r'\{color.*?\}', '', st)

st = "{color:#000000}So today while lurking around with the processing, I have stumbled across the main reason why it takes 15 minutes. {color}{color:#000000} {color}{color:#000000}It is because our trigger tooks 15 minutes to finishing sending the signal!{color}{color:#000000} {color}{color:#000000}"

re.sub(r'\{color.*?\}', '', st)

Выход:

'So today while lurking around with the processing, I have stumbled across the main reason why it takes 15 minutes.  It is because our trigger tooks 15 minutes to finishing sending the signal! '
...