Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -0,0 +1,13 @@
H
s/^/|/
,j
t0
t0
1s/^(.*)(.*)\|\1$/String \1\2 starts with \1/
1s/^(.*)\|(.*)/String \1 does not start with \2/
2s/^(.*)(.*)(.*)\|\2$/String \1\2\3 contains \2/
2s/^(.*)\|(.*)/String \1 does not contain \2/
3s/^(.*)(.*)\|\2$/String \1\2 ends with \2/
3s/^(.*)\|(.*)/String \1 does not end with \2/
,p
Q

View file

@ -0,0 +1,32 @@
package main
import "core:fmt"
import "core:strings"
main :: proc() {
using strings
s := "abracadabra"
s1 := "abr"
fmt.println( "1. ", s, " starts with ", s1, " --> ", has_prefix(s, s1))
fmt.println( "2. ", s, " contains ", s1, " --> ", contains (s, s1))
ndx := index(s, s1)
if ndx > -1 {
fmt.println(" 2.1. at location -> ", ndx)
ndx += len(s1)
for ndx < len(s) {
found := index(s[ndx:], s1)
if found > -1 {
fmt.println(" 2.2. at location -> ", found+ndx)
ndx += found+len(s1)
} else {
break
}
}
fmt.println(" 2.2. and that's all.")
}
fmt.println( "3. ", s, " ends with ", s1, " --> ", has_suffix(s, s1))
}

View file

@ -4,5 +4,5 @@ fn main() {
println(str.ends_with('zn')) // False
println(str.contains('bb')) // False
println(str.contains('ab')) // True
println(str.index('bc') or {-1}) // 1 // Vlang arrays are 0 based, so first char position is 0 and no result assigned -1
println(str.index('bc') or {-1}) // 1 // V arrays are 0 based; first char position is 0
}