as title
這兩天在看RE的部分
根據PYTHON 基金會的網站:
https://docs.python.org/2/library/re.html
7.2.5.7. Finding all Adverbs and their Positions¶
If one wants more information about all matches of a pattern than the matched
text, finditer() is useful as it provides instances of MatchObject instead of
strings. Continuing with the previous example, if one was a writer who wanted
to find all of the adverbs and their positions in some text, he or she would
use finditer() in the following manner:
>>> text = "He was carefully disguised but captured quickly by police."
>>> for m in re.finditer(r"\w+ly", text):
... print '%02d-%02d: %s' % (m.start(), m.end(), m.group(0))
07-16: carefully
40-47: quickly
關於""""for m in re.finditer(r"\w+ly", text):""""
這個部份我有一個疑問,
可是並不是所有的adv都有ly字尾.......
這種情形該怎麼處理呢?