Python中的文本处理,用于从字符串中删除十六进制颜色代码

问题描述 投票:0回答:1

我有一个带有一列文本的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
python html regex hex
1个回答
0
投票

尝试:

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! '
© www.soinside.com 2019 - 2024. All rights reserved.