- Perl6と.NETにしかできない(俺知っている限り)グループのなかのサブグループのデータが取れる
>>> m = regex.search(r"(\w{3})+", "123456789")
>>> m.captures(1)
['123', '456', '789']
>>> m.starts(1)
[0, 3, 6]
>>> m.ends(1)
[3, 6, 9]
>>> m.spans(1)
[(0, 3), (3, 6), (6, 9)][[:alpha:]], [[:^alpha:]]
>>> m = regex.search(r"(?P.*?)(?P \d+)(?P .*)", "pqr123stu") >>> print m["before"] pqr >>> print m["num"] 123 >>> print m["after"] stu >>> print len(m) 4 >>> print m[:] ('pqr123stu', 'pqr', '123', 'stu')
>>> regex.findall(r"..", "abcde") ['ab', 'cd'] >>> regex.findall(r"(?r)..", "abcde") ['de', 'bc']
スピードも1割ぐらいは早くなったと思う。re2に勝てないけどね。
ただこういうKiller Featuresあるかぎりみんな使い続けるでしょう 。。。
詳しくは http://pypi.python.org/pypi/regex で
3 comments:
Cool..
ဂူဂယ္ translate နဲ့ ဖတ္ရတယ္ :D
ပိုင္သြန္ ၂.၇ကိုေတာင္ သိပ္မျကြမ္းေသးေတာ့ ပိုင္သံုး ၃ ကို ဘယ္ေတာ့ ေျပာင္းသံုးရမလဲမသိ
That regex library is not built-in with any python version yet. you can download from the site I linked at the post. It works with both python2.5 ~ 2.7 and python 3.
Cooool..
အခုလို ရွင္းျပေပးတာ ေက်းဇူးပါ
Post a Comment