import re
stri = "Hello guys.\nHow are you doing?\nI hope you have sweet dreams tonight."
regex = re.compile("guys[.\n]*$")
print regex.findall(stri)
.
正規表現では、改行以外の任意の文字にすることができ、x または y のいずれかを意味[xy]
し*
、文字の後にはその文字の任意の数を意味し$
、文字列の末尾を示します。では、なぜ"guys[.\n]*$"
私に与えないの"guys.\nHow are you doing?\nI hope you have sweet dreams tonight."
ですか?