Last active
November 28, 2017 15:06
-
-
Save yoneda/08e45dc2d4ba849525caa4add5a8aa77 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# 正規表現のためのライブラリ「re」を導入 | |
import re | |
# 正規表現のパターン | |
# [\d]は任意の数値という意味、[\d+]で任意の数値が1個以上連続しているという意味 | |
# なので、(\d+年\d+月\d+日)は | |
# 任意の数値の連続 + 年 + 任意の数値の連続 + 月 + 任意の数値の連続 + 日 という意味になる。 | |
pattern = r"(\d+年\d+月\d+日)" | |
# 今回処理される対象のテキスト | |
text = "はじめまして。○○社の○○と申します。2017年12月5日、来社することは可能でしょうか?よろしくお願いします。" | |
result = re.search(pattern,text) | |
print(result.group()) # 2017年12月5日が表示 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment