-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rsplit error on empty strings #40244
Comments
Hi, can you show us a minimal example? |
It only seems to happen when the separator is at least 2.
a = ""
rsplit(a, "1")
1-element Vector{SubString{String}}:
""
rsplit(a, "12")
ERROR: BoundsError: attempt to access 0-element Vector{UInt8} at index
[0]
Stacktrace:
[1] _rsearchindex(s::Vector{UInt8}, t::Vector{UInt8}, _k::Int64)
@ Base ./strings/search.jl:461
[2] _rsearchindex(s::String, t::String, i::Int64)
@ Base ./strings/search.jl:446
[3] _rsearch
@ ./strings/search.jl:523 [inlined]
[4] findprev
@ ./strings/search.jl:556 [inlined]
[5] findlast
@ ./strings/search.jl:363 [inlined]
[6] _rsplit(str::String, splitter::String, limit::Int64,
keepempty::Bool, strs::Vector{SubString{String}})
@ Base ./strings/util.jl:492
[7] #rsplit#377
@ ./strings/util.jl:479 [inlined]
[8] rsplit(str::String, splitter::String)
@ Base ./strings/util.jl:479
[9] top-level scope
@ REPL[16]:1
…On Sat, 2021-03-27 at 20:27 -0700, Kenta Sato wrote:
Hi, can you show us a minimal example?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Thank you. I can reproduce the problem now. Julia 1.5.4:
Julia 1.6.0:
|
bicycle1885
added a commit
to bicycle1885/julia
that referenced
this issue
Mar 30, 2021
For an additional data point, the same error results from attempting an julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
julia> rsplit("hello", "he")
ERROR: BoundsError: attempt to access 5-element Vector{UInt8} at index [0]
Stacktrace:
[1] _rsearchindex(s::Vector{UInt8}, t::Vector{UInt8}, _k::Int64)
@ Base .\strings\search.jl:461
[2] _rsearchindex(s::String, t::String, i::Int64)
@ Base .\strings\search.jl:446
[3] _rsearch
@ .\strings\search.jl:523 [inlined]
[4] findprev
@ .\strings\search.jl:556 [inlined]
[5] _rsplit(str::String, splitter::String, limit::Int64, keepempty::Bool, strs::Vector{SubString{String}})
@ Base .\strings\util.jl:497
[6] #rsplit#377
@ .\strings\util.jl:479 [inlined]
[7] rsplit(str::String, splitter::String)
@ Base .\strings\util.jl:479
[8] top-level scope
@ REPL[3]:1 But matching a single character works: julia> rsplit("hello", "h")
2-element Vector{SubString{String}}:
""
"ello" And julia> split("hello", "lo")
2-element Vector{SubString{String}}:
"hel"
"" |
Merged
KristofferC
pushed a commit
that referenced
this issue
Jun 17, 2021
KristofferC
pushed a commit
that referenced
this issue
Jun 29, 2021
johanmon
pushed a commit
to johanmon/julia
that referenced
this issue
Jul 5, 2021
staticfloat
pushed a commit
that referenced
this issue
Dec 23, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, in case it's unintentional, rsplit gives me an error for empty strings in 1.6, it used to give [""]. Thanks!
The text was updated successfully, but these errors were encountered: