Skip to content

Commit

Permalink
without reverting JuliaLang#31312
Browse files Browse the repository at this point in the history
  • Loading branch information
eulerkochy authored Mar 15, 2019
1 parent 61c2086 commit 140d53d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion base/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ julia> chop(a, head = 5, tail = 5)
```
"""
function chop(s::AbstractString; head::Integer = 0, tail::Integer = 1)
SubString(s, nextind(s, firstindex(s), head), prevind(s, ncodeunits(s) + 1, tail) - 1)
if isempty(s)
return SubString(s)
end
SubString(s, nextind(s, firstindex(s), head), prevind(s, lastindex(s), tail))
end

# TODO: optimization for the default case based on
Expand Down

0 comments on commit 140d53d

Please sign in to comment.