mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
fix #3217 (string.replace)
This commit is contained in:
parent
e20ca28d5c
commit
98b81252b7
2 changed files with 4 additions and 1 deletions
|
@ -152,7 +152,7 @@ pub fn (s string) replace(rep, with string) string {
|
|||
break
|
||||
}
|
||||
idxs << idx
|
||||
idx++
|
||||
idx += rep.len
|
||||
}
|
||||
// Dont change the string if there's nothing to replace
|
||||
if idxs.len == 0 {
|
||||
|
|
|
@ -220,6 +220,9 @@ fn test_replace() {
|
|||
assert b.replace('charptr', 'byteptr') == '*byteptr'
|
||||
c :='abc'
|
||||
assert c.replace('','-') == c
|
||||
v :='a b c d'
|
||||
assert v.replace(' ',' ') == 'a b c d'
|
||||
|
||||
}
|
||||
|
||||
fn test_replace_each() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue