fix #3217 (string.replace)
parent
e20ca28d5c
commit
98b81252b7
|
@ -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…
Reference in New Issue