为什么这个正则表达式在Rubular中工作,而在Python中不工作?

2024-05-21 02:51:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用regex来解析SHOUTcast Total Time Spent Listening report。你知道吗

示例字符串:

#1         6,916,236.75      32,000,555        4,587,363         COOLfahrenheit 93
#2         4,457,026.25      3,328,957         1,168,349         idobi Radio: New. Music. Unfiltered. [url redacted]

正则表达式:

^\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$

Rubular下,返回:

Match 1
1.  6,916,236.75
2.  32,000,555
3.  4,587,363
4.  COOLfahrenheit 93
Match 2
1.  4,457,026.25
2.  3,328,957
3.  1,168,349
4.  idobi Radio: New. Music. Unfiltered. [URL redacted]

但是,当与Python的^{}一起使用时,返回None。我做错什么了?你知道吗


Tags: reportnewtimematchmusicregextotalradio