Regular Expression


regular expression cheet sheet



正規表現シンボルセット
^Matches the beginning of a line$Matches the end of the line.Matches any character\sMatches whitespace\SMatches any non-whitespace character*Repeats a character zero or more times*?Repeats a character zero or more times (non-greedy)+Repeats a character one or more times+?Repeats a character one or more times (non-greedy)[aeiou]Matches a single character in the listed set[^XYZ]Matches a single character not in the listed set[a-z0-9]The set of characters can include a range(Indicates where string extraction is to start)Indicates where string extraction is to end

Greedy Match


Regular Expressionを使用すると、結果は文字列が一致するときにより多くの文字が含まれる方向に戻ります.
import re

x = 'From: Using the : character'
y = re.findall('^F.+:', x)
print(y)
> ['From: Using the :']
コメントリンク
https://www.py4e.com/lectures3/Pythonlearn-11-Regex-Handout.txt
詳細
https://docs.python.org/3/howto/regex.html