Created
December 11, 2012 01:31
-
-
Save vkgtaro/4254995 to your computer and use it in GitHub Desktop.
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 | |
| regexp = re.compile(r"""\A \s+ # 空白スペース | |
| hoge # hoge に続いて | |
| \s # 空白スペース一個挟んだあと | |
| (.*)\Z # 最後までをマッチする | |
| """, re.X|re.M|re.S) | |
| print regexp.match(" hoge\nabc").groups() # => ('abc',) |
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
| # -*- 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