Standard library / bytes

bytes.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 []byte, chars string) int

Parameters & Attributes

NameTypeDescription
s[]byteInput 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 (  "bytes"  "fmt")
func main() {  fmt.Println(bytes.IndexAny([]byte("égo"), "og"))}
Go Reference