小编PJa*_*Jay的帖子

从字符串中删除与字母混合的数字

假设我有一个字符串,例如:

string = 'This string 22 is not yet perfect1234 and 123pretty but it can be.'
Run Code Online (Sandbox Code Playgroud)

我想从我的字符串中删除任何与单词混合的数字,例如'perfect1234'and '123pretty'但不是 '22',并获得如下输出:

string = 'This string 22 is not yet perfect and pretty but it can be.'
Run Code Online (Sandbox Code Playgroud)

有没有办法使用正则表达式或任何其他方法在 Python 中做到这一点?任何帮助,将不胜感激。谢谢!

python regex string

-7
推荐指数
2
解决办法
3823
查看次数

标签 统计

python ×1

regex ×1

string ×1