开发者

How to use structural pattern matching (match-case) with regex?

What would be a "pythonic" way of expressing regex'es with Python 3.10's (and later) match-case statements (i.e, pattern matc开发者_StackOverflow中文版hing)? It intuitively sounds like a good use case, but I cannot figure out a "clean" way of expressing something like:

s = "ham@spam.com"
match s:
    # cases matches s using regex
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜