1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fix string.count

This commit is contained in:
Alvydas Vitkauskas 2019-08-03 01:18:19 +03:00 committed by Alexander Medvednikov
parent d4c07d9b66
commit bfdce806c4

View File

@ -460,13 +460,14 @@ pub fn (s string) count(substr string) int {
return 0
}
mut n := 0
mut i := 0
for {
i := s.index(substr)
i := s.index_after(substr, i)
if i == -1 {
return n
}
i += substr.len
n++
s = s.right(i+substr.len)
}
}