Skip to content

Instantly share code, notes, and snippets.

@vkgtaro
Created December 11, 2012 01:31
Show Gist options
  • Select an option

  • Save vkgtaro/4254995 to your computer and use it in GitHub Desktop.

Select an option

Save vkgtaro/4254995 to your computer and use it in GitHub Desktop.
import re
regexp = re.compile(r"""\A \s+ # 空白スペース
hoge # hoge に続いて
\s # 空白スペース一個挟んだあと
(.*)\Z # 最後までをマッチする
""", re.X|re.M|re.S)
print regexp.match(" hoge\nabc").groups() # => ('abc',)
# -*- coding: utf-8 -*-
import re
not_unicode_regexp = re.compile(r"(\d+)")
print not_unicode_regexp.match(u"01234") # => None
unicode_regexp = re.compile(r"(\d+)", re.U)
print unicode_regexp.match(u"12345").groups() # => ('12345',)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment