ANN: StringUnits.jl

mnemnion
Wed, 27 Mar 2024 22:09:52 +0000
Package Announcements

Inspired by this lengthy thread, which I jumped into somewhat later, I’ve implemented the idea as StringUnits.jl.

Pretty straightforward:

julia> "aβc∅👨🏻‍🌾efg"[2ch:4ch]
"βc∅"

julia> "aβc∅👨🏻‍🌾efg"[5gr]
"👨🏻‍🌾"

julia> "aβc∅👨🏻‍🌾efg"[3gr:6gr]
"c∅👨🏻‍🌾e"

Units can be mixed:

julia> "aβc∅👨🏻‍🌾efg"[2ch+1gr:3ch+2gr]
"c∅👨🏻‍🌾e"

Currently, negative indices of any sort are not supported, although I’d like to add that, time permitting.

Oh, and you can use normal byte-based indices as well:

julia> "aβc∅👨🏻‍🌾efg"[5:5+3gr]
"∅👨🏻‍🌾ef"

More details may be found in the documentation.

9 posts - 5 participants

Read full topic