import re str = ''' This is Heima Itcast ''' a = re.findall('This is(.*?)Itcast',str) b = re.findall('This is(.*?)Itcast',str,re.S) print('a is ',a) print('b is ',b)