【ときどきpython】reと正規表現
正規表現メモ
\d
数字
\w
a-zA-Z0-9_
\w+
一つ以上の単語文字が続くシーケンス
あ
findall
パターンと対象のテキストを指定、マッチしたものをリストで返却
メールアドレスマッチ
code:mail.py
import re
text = "My email is example@test.com and my friend's is hello@world.net."
matches = re.findall(r'
\w\-._
+@
\w\-._
+\.
A-Za-z
+', text)
print(matches)
==>
'example@test.com', 'hello@world.net'
ときどきpython