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:
parent
d4c07d9b66
commit
bfdce806c4
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user