Closed. This question needs details or clarity。它当前不接受答案。












想改善这个问题吗?添加详细信息并通过editing this post阐明问题。

6年前关闭。



Improve this question





我有字符串值,因为我只需要获取不含逗号或分号的文本,如下面的示例输入所示:

<LINE>002:OR,004:0001,002:01,007:SCEM_02,000:, 002:PC;/</LINE>


我的输出应该像这样:

OR 0001 01 SCEM_02 PC


(即)没有逗号,分号,冒号。

为此,我需要使用什么功能?等待你的答复。

问候,
喜悦

最佳答案

使用正则表达式
在python中

import re
re.findall(r'.*(:[\w]+,?)+', "<LINE>002:OR,004:0001,002:01,007:SCEM_02,000:, 002:PC;/</LINE> ");


希望有帮助!!!

09-26 01:02