LastIndex in Go

Posted by GoDoc
Public (Editable by Users)

LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s.

Go
Edit
package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.Index("go gopher", "go"))
	fmt.Println(strings.LastIndex("go gopher", "go"))
	fmt.Println(strings.LastIndex("go gopher", "rodent"))
}