mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
builtin: add string.trim_indexes method, that can be used in string.trim, but also separately from it (#16144)
This commit is contained in:
parent
b6faf82911
commit
a139bed785
2 changed files with 20 additions and 3 deletions
|
@ -538,6 +538,16 @@ fn test_trim() {
|
|||
assert 'aaabccc'.trim('ac') == 'b'
|
||||
}
|
||||
|
||||
fn test_trim_indexes() {
|
||||
mut left, mut right := 0, 0
|
||||
left, right = '- -- - '.trim_indexes(' -')
|
||||
assert left == 0 && right == 0
|
||||
left, right = '- hello-world!\t'.trim_indexes(' -\t')
|
||||
assert left == 2 && right == 14
|
||||
left, right = 'abc'.trim_indexes('ac')
|
||||
assert left == 1 && right == 2
|
||||
}
|
||||
|
||||
fn test_trim_left() {
|
||||
mut s := 'module main'
|
||||
assert s.trim_left(' ') == 'module main'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue