Standard library / strings

strings.LastIndexFunc()

Returns the byte offset of the last rune accepted by f, or -1. Expected stdout: '3\n'.

Formal Syntax & Structure

go syntaxgo
func LastIndexFunc(s string, f func(rune) bool) int

Parameters & Attributes

NameTypeDescription
sstringInput text or sequence.
ffunc(rune) boolPredicate over decoded runes.

Return Value

int

Returns the byte offset of the last rune accepted by f, or -1.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings"  "unicode")
func main() {  fmt.Println(strings.LastIndexFunc("1é2", unicode.IsDigit))}
Go Reference