Check whether text contains x numbers in a row [cl

2019-06-14 16:08发布

Is there an option to check whether the given text contains x numbers in a row?

Example:

da$ c0220 -> True
dsad458d69 -> False

I think I should use regular expressions but I can't figure out how.

1条回答
Root(大扎)
2楼-- · 2019-06-14 16:32

The regex below checks for 10 consecutive numbers

\d{10}

In Python this becomes

if re.search(r"\d{10}", subject):
    # Successful match
else:
    # Match attempt failed
查看更多
登录 后发表回答