Python Regex escape operator \ in substitutions & raw strings
问题 I don't understand the logic in the functioning of the scape operator \ in python regex together with r' of raw strings. Some help is appreciated. code: import re text=' esto .es 10 . er - 12 .23 with [ and.Other ] here is more ; puntuation' print('text0=',text) text1 = re.sub(r'(\s+)([;:\.\-])', r'\2', text) text2 = re.sub(r'\s+\.', '\.', text) text3 = re.sub(r'\s+\.', r'\.', text) print('text1=',text1) print('text2=',text2) print('text3=',text3) The theory says: backslash character ('\') to