Skip to content

Commit cf397be

Browse files
committed
Use a MULTILINE anchored regex when removing carriage returns
This seems a lot faster on long strings (8s down to 8ms for a 120000 character string).
1 parent 26555e5 commit cf397be

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

nbval/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ def sanitize(self, s):
795795
return s
796796

797797

798-
carriagereturn_pat = re.compile(r'.*\r(?=[^\n])')
798+
carriagereturn_pat = re.compile(r'^.*\r(?=[^\n])', re.MULTILINE)
799799
backspace_pat = re.compile(r'[^\n]\b')
800800

801801

0 commit comments

Comments
 (0)