Standard library / bytes
bytes.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 []byte, f func(r rune) bool) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | []byte | Input text or sequence. |
| f | func(r 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 ( "bytes" "fmt" "unicode")
func main() { fmt.Println(bytes.LastIndexFunc([]byte("1é2"), unicode.IsDigit))}