我在数据帧中有一个字符串列,我想从中提取最后一次出现反斜杠的速率。
After so many requests, this is Bretagne. She was the last surviving 9/11 search dog, and our second ever 14/10. RIP*
我想要14/10
尝试此代码以获取此句子中所有日期的列表
import re
re.findall(r"d+/d+","After so many requests, this is Bretagne. She was the last surviving 9/11 search dog, and our second ever 14/10. RIP* ")
要获得第二项,只需在此列表中选择第二项即可
此正则表达式有效:
>>> s = "After so many requests, this is Bretagne. She was the last surviving 9/11 search dog, and our second ever 14/10. RIP*"
>>> re.findall("d+/(?=[^/]*$)d+", s)
['14/10']