print(re.search('^From', 'From Here to Eternity')) # <re.Match object; span=(0, 4), match='From'>
print(re.search('^From', 'Reciting From Memory')) # None
print(re.search('}$', '{block}')) # <re.Match object; span=(6, 7), match='}'>
print(re.search('}$', '{block} ')) # None
print(re.search('}$', '{block}\n')) # <re.Match object; span=(6, 7), match='}'>
p = re.compile(r'\bclass\b')
print(p.search('no class at all')) # <re.Match object; span=(3, 8), match='class'>
print(p.search('the declassified algorithm')) # None
print(p.search('one subclass is')) # None
p = re.compile('(a(b)c)d')
m = p.match('abcd')
m.group(0) # 'abcd'
m.group(1) # 'abc'
m.group(2) # 'b'
.split(string, maxsplit=0) : maxsplit 값이 0이 아니면 최대 maxsplit번 분할만 이루어지고, 나머지 문자열은 리스트의 마지막 요소로 반환
p = re.compile(r'\W+')
p.split('This is a test, short and sweet, of split().')
# ['This', 'is', 'a', 'test', 'short', 'and', 'sweet', 'of', 'split', '']
p.split('This is a test, short and sweet, of split().', 3)
# ['This', 'is', 'a', 'test, short and sweet, of split().']
.sub(replacement, string, count=0)
string 에서 가장 왼쪽에 나타나는 겹쳐지지 않은 RE의 일치를 replacement로 치환
count는 치환될 패턴 일치의 최대 수
p = re.compile('(blue|white|red)')
p.sub('colour', 'blue socks and red shoes') # 'colour socks and colour shoes'
p.sub('colour', 'blue socks and red shoes', count=1) # 'colour socks and red shoes'
p = re.compile('(blue|white|red)')
p.subn('colour', 'blue socks and red shoes') # ('colour socks and colour shoes', 2)
p.subn('colour', 'no colours at all') # ('no colours at all', 0)