开发者

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

开发者 https://www.devze.com 2022-12-07 17:47 出处:网络
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 g

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

精彩评论

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