如何将特定单词(即ABC)替换为字母数字/数字,如下图所示
输入数据
what is ABC s123 doing 77 here?
what is abc aA574 doing 89 here?
what is ABC-X187 doing here?
what is aBC^984 doing here?
what is Abc647 doing here?
预期产出数据
what is ABCS123 doing 77 here?
what is ABCAA574 doing 89 here?
what is ABCX187 doing here?
what is ABC984 doing here?
what is ABC647 doing here?
注意:任何字母数字都可以跟在ABC后面。这里显示的数字只是示例,不需要硬编码解决方案中的数字。你知道吗
EDIT1:刚刚尝试了提议的解决方案。当特殊字符是空格时,它不起作用。所以请移除重复标签。你知道吗
编辑2:请按问题处理ABC的案件。你知道吗
您可以使用:
或者
来自Series.str.replace的文档
您可以使用以下代码:
regex101的详细信息:https://regex101.com/r/gGK8fJ/2
相关问题 更多 >
编程相关推荐