Created
October 5, 2012 07:54
-
-
Save yuyay/3838642 to your computer and use it in GitHub Desktop.
RTの発信元を抽出する正規表現
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
r = re.compile("RT @([0-9a-zA-Z_]{1,15}):(?!.*RT @[0-9a-zA-Z_]{1,15})\s?(.*?)$") | |
text = "RT @aaa: あああ RT @bbb: いいい" | |
s = r.search(text) | |
s.group(0) # マッチした全体(RT @bbb: いいい) | |
s.group(1) # 発信者screen_name(bbb) | |
s.group(2) # 発信情報(いいい) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment