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) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text or sequence. |
| f | func(rune) bool | Predicate 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))}