Skip to content

Commit

Permalink
Fix re.sub to also capture \t and \r
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarobartt committed May 31, 2024
1 parent 59471c1 commit 287ed8a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/distilabel/steps/tasks/improving_text_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ def escape_backslashes_in_values(s):
def replace_backslashes(match):
return (
match.group(1)
+ re.sub(r"(?<!\\)\n", r"\\n", match.group(2))
+ re.sub(
r"(?<!\\)(\n|\r|\t)",
r"\\\1",
match.group(2), # .encode("unicode_escape").decode("utf-8"),
)
+ match.group(3)
)

Expand Down

0 comments on commit 287ed8a

Please sign in to comment.