Regular expression with backslash in Python3

后端 未结 2 503
一向
一向 2021-01-24 14:58

I\'m trying to match a specific substring in one string with regular expression, like matching \"\\ue04a\" in \"\\ue04a abc\". But something seems to b

2条回答
  •  没有蜡笔的小新
    2021-01-24 15:54

    This should help.

    import re
    m = re.match(r'(\\ue\d+[a-z]+)', r"\ue04a abc")
    if m:
        print( m.group() )
    

    Output:

    \ue04a
    

提交回复
热议问题