🌐
Codecademy
codecademy.com › docs › go › strings › lastindex()
Go | Strings | LastIndex() | Codecademy
September 26, 2023 - Returns the index value of the last occurrence of a substring in the original string.
🌐
Go Packages
pkg.go.dev › strings
strings package - strings - Go Packages
LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s. ... package main import ( "fmt" "strings" ) func main() { fmt.Println(strings.LastIndexByte("Hello, world", 'l')) fmt.Println(strings.LastIndexByte("Hello, world", 'o')) fmt.Println(strings.Last...
🌐
GeeksforGeeks
geeksforgeeks.org › go language › strings-lastindex-function-in-golang-with-examples
strings.LastIndex() Function in Golang With Examples - GeeksforGeeks
April 19, 2020 - strings.LastIndex() function in the Golang returns the starting index of the occurrence of the last instance of a substring in a given string. If the substring is not found then it returns -1. Thus, this function returns an integer value.
🌐
TutorialsPoint
tutorialspoint.com › how-to-find-the-last-index-value-of-a-string-in-golang
How to find the last index value of a string in Golang?
package main import ( "fmt" "strings" ) func main() { // Initializing the Strings p := "Programming Language" q := "String Function" r := "Golang String Function" s := "1234512345" // Display the Strings fmt.Println("String 1:", p) fmt.Println("String 2:", q) fmt.Println("String 3:", r) fmt.Println("String 4:", s) // Using the LastIndex Function test1 := strings.LastIndex(p, "ge") test2 := strings.LastIndex(q, "C") test3 := strings.LastIndex(r, "ng") test4 := strings.LastIndex(s, "23") // Display the LastIndex Output fmt.Println("LastIndex of 'ge' in String 1:", test1) fmt.Println("LastIndex of 'C' in String 2:", test2) fmt.Println("LastIndex of 'ng' in String 3:", test3) fmt.Println("LastIndex of '23' in String 4:", test4) }
🌐
IncludeHelp
includehelp.com › golang › strings-lastindex-function-with-examples.aspx
Golang strings.LastIndex() Function with Examples
August 17, 2021 - // Golang program to demonstrate the // example of strings.LastIndex() Function package main import ( "fmt" "strings" ) func main() { var str string var substr string var index int str = "Hello, world!" substr = "world" index = strings.LastIndex(str, substr) if index >= 0 { fmt.Printf("Last index of %q in %q is %d.\n", substr, str, index) } else { fmt.Printf("%q does not found in %q.\n", substr, str) } str = "Hello, world!" substr = "l" index = strings.LastIndex(str, substr) if index >= 0 { fmt.Printf("Last index of %q in %q is %d.\n", substr, str, index) } else { fmt.Printf("%q does not found in %q.\n", substr, str) } str = "Hello!
🌐
Educative
educative.io › answers › what-is-the-lastindex-function-in-golang
What is the LastIndex function in Golang?
The LastIndex function is used to find the index of the last instance of a substring in a string value.
🌐
GeeksforGeeks
geeksforgeeks.org › go language › how-to-find-the-last-index-value-of-specified-string-in-golang
How to find the last index value of specified string in Golang? - GeeksforGeeks
July 12, 2025 - These functions are defined under ... these functions: 1. LastIndex: This function is used to find the index value of the last instance of the given string from the original string....
🌐
Codekru
codekru.com › home › strings.lastindex() method in golang
strings.LastIndex() method in Golang - Codekru
September 25, 2022 - This means that if there are multiple occurrences of the string substr in the string s, then it is going to return the last occurrence of the string substr · What does it return? LastIndex() method returns an int value representing the last occurrence of the string substr within the string s.
🌐
Thedeveloperblog
thedeveloperblog.com › default_002
Golang Index, LastIndex: strings Funcs
Golang program that uses LastIndex package main import ( "fmt" "strings" ) func main() { input := "one two one" // Get last index, searching from right to left.
🌐
Dot Net Perls
dotnetperls.com › index-go
Go - strings.Index, LastIndex Funcs - Dot Net Perls
package main import ( "fmt" "strings" ) func main() { input := "one two one" // Get last index, searching from right to left. i := strings.LastIndex(input, "one") fmt.Println(i) }
Find elsewhere
🌐
TutorialKart
tutorialkart.com › golang-tutorial › golang-find-index-of-last-occurrence-of-substring-in-string
How to find index of Last Occurrence of Substring in a String in Go?
May 28, 2021 - LastIndex function returns an integer that represents the position of last occurrence of substr in str. In the following program, we will take a string Welcome to Go Tutorial, Go Examples and find the index of last occurrence of substring Go.
🌐
GeeksforGeeks
geeksforgeeks.org › go language › strings-lastindexbyte-function-in-golang-with-examples
strings.LastIndexByte() Function in Golang With Examples - GeeksforGeeks
April 28, 2025 - fmt.Println(strings.LastIndexByte("geeksforgeeks", 'g')) // returns the last index of 'k' in string. fmt.Println(strings.LastIndexByte("geekgeekgeek", 'k')) } Output: ... // Golang program to illustrate the // strings.LastIndexByte() Function package main // importing fmt and strings import ( "fmt" "strings" ) // calling main method func main() { // performs case-insensitive search(returns -1).
🌐
Go
go.dev › pkg › strings
Package strings - The Go Programming Language
Join concatenates the elements of its first argument to create a single string. The separator string sep is placed between elements in the resulting string. ... LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s.
🌐
Go Forum
forum.golangbridge.org › getting help
Is there a strings.LastIndex that counts runes instead of bytes? - Getting Help - Go Forum
February 19, 2016 - Learning Go. Is there a strings.LastIndex that counts runes instead of bytes? s1 := "test- 1" // using hyphen fmt.Println(strings.LastIndex(s1, " ")) // outputs 5 s2 := "test— 2" // using long dash instead of hyphen …
🌐
Golangdoc
golangdoc.github.io › pkg › 1.8.5 › strings › index.html
strings - The Go Programming Language
Join concatenates the elements of a to create a single string. The separator string sep is placed between elements in the resulting string. ... LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
🌐
GitHub
github.com › golang › go › blob › master › src › strings › strings.go
go/src/strings/strings.go at master · golang/go
func LastIndex(s, substr string) int { n := len(substr) switch { case n == 0: return len(s) case n == 1: return bytealg.LastIndexByteString(s, substr[0]) case n == len(s): if substr == s { return 0 · } return -1 · case n > len(s): return -1 ·
Author   golang
🌐
myCompiler
mycompiler.io › view › IFzuYJS3c1I
strings.LastIndex in Go (Go) - myCompiler
March 25, 2024 - package main import ( "fmt" "strings" ) func main() { str := "hello, world!" idx := strings.LastIndex(str, ",") fmt.Println(strings.TrimSpace(str[idx+1:])) }
Published   Mar 25, 2024
🌐
Go Packages
pkg.go.dev › rsc.io › xstd › go1.9.3 › strings
strings package - rsc.io/xstd/go1.9.3/strings - Go Packages
September 29, 2022 - LastIndexAny returns the index of the last instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s. ... package main import ( "fmt" "rsc.io/xstd/go1.9.3/strings" ) func main() { fmt.Println(strings.LastIndexAny("go gopher", "go")) ...