Skip to content

Commit

Permalink
Off by one error in len
Browse files Browse the repository at this point in the history
  • Loading branch information
aviks authored Apr 5, 2021
1 parent 575282c commit 4080202
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/preprocessing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ function remove_patterns(s::SubString{T}, rex::Regex) where T <: String
data = codeunits(s.string)
ibegin = 1
for m in eachmatch(rex, s)
len = m.match.offset-ibegin+1
len = m.match.offset-ibegin
next = nextind(s, lastindex(m.match)+m.match.offset)
if len > 0
write(iob, SubString(s, ibegin, ibegin+len))
Expand All @@ -490,7 +490,7 @@ function remove_patterns(s::SubString{T}, rex::Regex) where T <: String
end
ibegin = next
end
len = lastindex(s) - ibegin + 1
len = lastindex(s) - ibegin
(len > 0) && write(iob, SubString(s, ibegin, ibegin+len))
String(take!(iob))
end
Expand Down

0 comments on commit 4080202

Please sign in to comment.