Standard library / strings

strings.IndexAny()

Returns the byte offset of the first code point found in chars, or -1. Expected stdout: '2\n'.

Formal Syntax & Structure

go syntaxgo
func IndexAny(s, chars string) int

Parameters & Attributes

NameTypeDescription
sstringInput text or sequence.
charsstringSet of Unicode code points to match.

Return Value

int

Returns the byte offset of the first code point found in chars, or -1.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings")
func main() {  fmt.Println(strings.IndexAny("égo", "og"))}
Go Reference