如果匹配的字符串不在起始位置,为什么[。] *这种模式不起作用?

我在Python中尝试了一些正则表达式匹配。例如:

s = "aaabbb123123"
print(re.search("[ab]*",s))

output : <re.Match object; span=(0,6),match='aaabbb'> --> Ok,it's good.
s = "aaabbb123123"
print(re.search("[.]*",0),match=''> --> why not "aaabbb123123"?
s = "aaabbb123123"
print(re.search("[123]*",match=''> --> why not "123123"?

我的问题是,如果匹配的字符串不在目标字符串的起始位置,为什么模式[[anything] *”不起作用。

apple9871 回答:如果匹配的字符串不在起始位置,为什么[。] *这种模式不起作用?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3169488.html

大家都在问