Matching only a unicode letter in Python re

前端 未结 1 1108
没有蜡笔的小新
没有蜡笔的小新 2020-12-01 17:51

I have a string from which i want to extract 3 groups:

\'19 janvier 2012\' -> \'19\', \'janvier\', \'2012\'

Month name could contain non

相关标签:
1条回答
  • 2020-12-01 18:35

    You can construct a new character class:

    [^\W\d_]
    

    instead of \w. Translated into English, it means "Any character that is not a non-alphanumeric character ([^\W] is the same as \w), but that is also not a digit and not an underscore".

    Therefore, it will only allow Unicode letters (if you use the re.UNICODE compile option).

    0 讨论(0)
提交回复
热议问题