Skip to content

Instantly share code, notes, and snippets.

@dogrunjp
Created March 27, 2014 09:37
Show Gist options
  • Save dogrunjp/9803807 to your computer and use it in GitHub Desktop.
Save dogrunjp/9803807 to your computer and use it in GitHub Desktop.
Pythonはリスト内包表記の中で正規表現が使えるとのこと。テキスト処理に使えそう。
>>>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