Closed
Description
eachmatch
is supposed to return an m::RegexMatch
where m.match
is a SubString
of the original string, but for a StringView
it is erroneously making a copy of the data. (m.match
is a substring, but m.match.string
is a copy rather than the original StringView
object):
julia> s = "foo 1234 bar"
"foo 1234 bar"
julia> first(eachmatch(r"[0-9]+", s))
RegexMatch("1234")
julia> dump(first(eachmatch(r"[0-9]+", s)))
RegexMatch
match: SubString{String}
string: String "foo 1234 bar"
offset: Int64 4
ncodeunits: Int64 4
captures: Array{Union{Nothing, SubString{String}}}((0,))
offset: Int64 5
offsets: Array{Int64}((0,)) Int64[]
regex: Regex
pattern: String "[0-9]+"
compile_options: UInt32 0x040a0002
match_options: UInt32 0x40000000
regex: Ptr{Nothing} @0x0000600003ed86c0
julia> sv = StringView(codeunits(s))
"foo 1234 bar"
julia> dump(first(eachmatch(r"[0-9]+", sv)))
RegexMatch
match: SubString{String}
string: String "1234"
offset: Int64 0
ncodeunits: Int64 4
captures: Array{Union{Nothing, SubString{String}}}((0,))
offset: Int64 5
offsets: Array{Int64}((0,)) Int64[]
regex: Regex
pattern: String "[0-9]+"
compile_options: UInt32 0x040a0002
match_options: UInt32 0x40000000
regex: Ptr{Nothing} @0x0000600003ed4840