Skip to content

Instantly share code, notes, and snippets.

@ichiren1
Forked from dogrunjp/python_re_in_lc.py
Last active August 29, 2015 14:25
Show Gist options
  • Save ichiren1/2875f9684aea9c0732b9 to your computer and use it in GitHub Desktop.
Save ichiren1/2875f9684aea9c0732b9 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