python版本为3.6.1
源代码如下:
import re
patt = '[A-Za-z]+ [A-Za-z]+'
name1 = 'Lu minfei'
name2 = 'Nuo nuo'
name3 = 'Chu zihang'
m = re.match(patt, name1)
m1 = re.match(patt, name2)
m2 = re.match(patt, name3)
if m is not None:
print(m.group())
if m is not None:
print(m1.group())
if m is not None:
print(m2.group())
任意单词为[A-Za-z],匹配一个或多个为’+’,即可写出答案。