-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavior
Description
I'm new to the language, so can't be confident, but I was pointed to submit this issue by the #julia IRC channel. I couldn't find a reference to this behaviour in the issues listed here or on the mailing list.
The bug (if that is what it is) appears to be with subsitution strings when the substitution string is placed inside arrays.
str = "tough"
f = r"(^[crt])ough"
t = s"\1ou2f"
println(replace(str, f, t))
#gives 'tou2f' (as expected)
z = [f,""]
y = [t,""]
println(replace(str, z[1], y[1]))
#gives '\1ou2f'
println(replace(str, z[1], t))
#'tou2f'
println(replace(str, f, y[1]))
#'\1ou2f'
#y[1] rather than t is the issue.The same behaviour appears if you do e.g. y = [s"\1ou2f",""], and the use of \g<1> rather than \1 does not resolve it. I would guess that the capture group is not being passed to the substitution string at all (\0 similarly produces \0ou2f in the above).
Version Info:
Julia Version 0.4.3
Commit a2f713d (2016-01-12 21:37 UTC)
Platform Info:
System: Linux (x86_64-unknown-linux-gnu)
CPU: Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
WORD_SIZE: 64
BLAS: libopenblas (DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas
LIBM: libm
LLVM: libLLVM-3.3
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavior