i********g 发帖数: 72 | 1 In your code, r'x\nxx' is pattern, and r'aaax\nxxyyy' is the string to match.
You need to remove 'r' to get right. r'aaax\nxxyyy' is raw string
interpreted as [ aaax\nxxyyy ], However, 'aaax\nxxyyy' is NOT raw string, '\
n' is interpreted as new line;
If the pattern isn’t found, meaning xNEWLINExx is not equal to [x\nxx],
string is returned unchanged. That's why you get your first results.
Make sure the pattern get match.
Hope this helps!
’r |
|