我写一个正则表达式表达式提取的符号(#/ - ),接着是word.For例如,考虑串正则表达式中提取多个符号,随后字在字符串-python
s= "the amount is 5/10 of the original. The #2 number should be extracted on the dd/yy"
表达正则表达式是
r= re.search(r'(/|#).*\\s+',s)
其中我得到用于上述的输出是无在哪里,因为我预期它显示
/10 #2 /yy
我的正则表达式有什么问题。
首先,你的正则表达式是错误的;其次,如果没有发现匹配,如果发现匹配的正则表达式对象re.search返回无。改用re.findall()。 –
@BhawandeepSingla:我知道我的正则表达式有问题。这是它返回None。由于我不确定有什么问题,我正在寻求帮助,以便有人能够指出我的错误来帮助我。 – shan