Created
March 27, 2014 09:37
-
-
Save dogrunjp/9803807 to your computer and use it in GitHub Desktop.
Pythonはリスト内包表記の中で正規表現が使えるとのこと。テキスト処理に使えそう。
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 | |
>>>list = ['a', '1', 'bc', '-b', '2a','100'] | |
>>>r = re.compile("[a-z]") | |
>>>[x for x in list if r.mathch(x)] | |
['a','bc'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment