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

string: fix trim_prefix and trim_suffix methods (#5572)

This commit is contained in:
nyaascii
2020-06-30 15:44:53 +02:00
committed by GitHub
parent af56b01a41
commit f10d2bb75f
2 changed files with 18 additions and 2 deletions

View File

@ -921,14 +921,14 @@ pub fn (s string) trim_right(cutset string) string {
pub fn (s string) trim_prefix(str string) string {
if s.starts_with(str) {
return s.replace(str, "")
return s[str.len..]
}
return s
}
pub fn (s string) trim_suffix(str string) string {
if s.ends_with(str) {
return s.replace(str, "")
return s[..s.len-str.len]
}
return s
}