Python – Getting dot to match newlines as well

re.DOTALL / re.S – means dot will match newlines

re.MULTILINE / re.M – means that ^$ will only match start and end of string.  By default they match start and end of each line

match = re.search(r'^(.+lorem ipsum)(.+)(donor kebab.+)$', s, re.DOTALL + re.MULTILINE)

					

Leave a Reply