Python Regex寻找alpha&;文本中的数字词

Python Regex寻找alpha&;文本中的数字词,python,regex,Python,Regex,我有这篇文章: due to previous assess c6c587469 and 4ec0f198 nearest and with fill station in the citi becaus of our satisfact in the d4a29a already averaging my thoughts on e977f33588f react to 我想删除所有“字母和数字”单词 在输出中,我想要 due to previous assess and nearest

我有这篇文章:

due to previous assess c6c587469 and 4ec0f198
nearest and with fill station in the citi
becaus of our satisfact in the d4a29a already
averaging my thoughts on e977f33588f react to
我想删除所有“字母和数字”单词

在输出中,我想要

due to previous assess and 
nearest and with fill station in the citi
becaus of our satisfact in the already
averaging my thoughts on react to
我试过了,但没用

df_colum = df_colum.str.replace('[^A-Za-z0-9\s]+', '')
有正则表达式专家吗

谢谢

尝试使用此正则表达式:

df_colum = df_colum.str.replace('\w*\d\w*', '')

这里有一种没有正则表达式的方法:

def parser(x):
    return ' '.join([i for i in x.split() if not any(c.isdigit() for c in i)])

df['text'] = df['text'].apply(parser)

print(df)

                                        text
0                 due to previous assess and
1  nearest and with fill station in the citi
2     becaus of our satisfact in the already
3          averaging my thoughts on react to
这一条应该有效:

df_colum = df_colum.str.replace('(?:[0-9][^ ]*[A-Za-z][^ ]*)|(?:[A-Za-z][^ ]*[0-9][^ ]*)', '')

可以找到正则表达式的解释

您可以查找一个数字与字母
\d[a-z]
[a-z]\d
的位置,然后匹配到末尾:

(?i)\b(?:[a-z]+\d+|\d+[a-z]+)\w*\b *

  • (?i)
    启用不区分大小写
  • (?:…)
    构造一个非捕获组
  • \b
    表示单词边界
Python代码:

re.sub(r"\b(?:[a-z]+\d+|\d+[a-z]+)\w*\b *", "", str)
尝试