In [1]:
import re

In [2]:
p = re.compile('[a-z]+')
print(p.fullmatch('abc'))


<re.Match object; span=(0, 3), match='abc'>

In [3]:
print(p.fullmatch('abc123'))


None

In [4]:
s = 'abc'

if p.fullmatch(s):
    print('match')
else:
    print('no match')


match

In [5]:
s = 'abc123'

if p.fullmatch(s):
    print('match')
else:
    print('no match')


no match

In [6]:
p = re.compile('[a-z]+$')
print(p.match('abc'))


<re.Match object; span=(0, 3), match='abc'>

In [7]:
print(p.match('abc123'))


None

In [8]:
p = re.compile('[a-z]+')
print(p.search('123abcABC'))


<re.Match object; span=(3, 6), match='abc'>

In [9]:
print(p.search('123ABC'))


None

In [10]:
p = re.compile('[a-z]+')
result = p.findall('123abcABCxyz')
print(result)


['abc', 'xyz']

In [11]:
print(type(result))


<class 'list'>

In [12]:
print(type(result[0]))


<class 'str'>

In [13]:
print(p.findall('123ABC'))


[]

In [14]:
s_result = ''.join(p.findall('123abcABCxyz'))
print(s_result)


abcxyz

In [15]:
print(len(s_result))


6

In [16]:
print(len('🇯🇵'))


2