String matching: Difference between revisions
Content added Content deleted
No edit summary |
(Added Odin variant) |
||
Line 3,406: | Line 3,406: | ||
that other cloud looks like a llama" "cloud" ;; |
that other cloud looks like a llama" "cloud" ;; |
||
- : bool * int = (true, 2) |
- : bool * int = (true, 2) |
||
=={{header|Odin}}== |
|||
<syntaxhighlight lang="odin">package main |
|||
import "core:fmt" |
|||
import "core:strings" |
|||
main :: proc() { |
|||
using strings |
|||
s := "Hello world" |
|||
fmt.println(has_prefix(s, "He"), contains(s, "wo"), has_suffix(s, "ld")) |
|||
// Output: true true true |
|||
fmt.println(index(s, "wo")) |
|||
// Output: 6 |
|||
}</syntaxhighlight> |
|||
=={{header|Oforth}}== |
=={{header|Oforth}}== |