replace("123\n", r"(\n)", s"\1")
is OK, but replace("123\n", r"(\n)", s"\r\1")
reports “Bad replacement string”. Is this a bug of function replace
?
It might be considered a bug in the string literal for SubstitutionString
:
The following works, where the SubstitutionString
is created directly:
(Note that below \1
is displayed as \l
because discourse markdown renders as a backtick, and I don’t know how to escape it)
Julia-0.5.1> s = Base.SubstitutionString("\r\\l")
s"\r\\l"
Julia-0.5.1> replace("123\n", r"(\n)", s)
"123\r\n"
It appears that s"\r\1"
creates a 4-character string "\\r\\l"
, rather than the 3-character string "\r\\l"
.
Perhaps file an issue?
Thanks