LastIndexFunc in Go

Posted by GoDoc
Public (Editable by Users)

LastIndexFunc returns the index into s of the last Unicode code point satisfying f(c), or -1 if none do.

Go
Edit
package main

import (
	"fmt"
	"strings"
	"unicode"
)

func main() {
	fmt.Println(strings.LastIndexFunc("go 123", unicode.IsNumber))
	fmt.Println(strings.LastIndexFunc("123 go", unicode.IsNumber))
	fmt.Println(strings.LastIndexFunc("go", unicode.IsNumber))
}