Python正則表達式之\b

\b 稱爲單詞邊界(word boundary)符.python 例如只想匹配 My cat is bad.中的cat 能夠使用 \bcat\bexpress import re harsh_str = [ 'hello', 'Cat', ' cat', 'cat h', 'CAT', 'CAt-h', 'Cat_h'] #re.I要在compile的時候指定,注意\b在python中是回退符,正
相關文章
相關標籤/搜索