Golang bytes.LastIndexAny() function example
package bytes
LastIndexAny interprets given input as a sequence of UTF-8-encoded Unicode code points. It returns the byte index of the last occurrence of the search key in Unicode code points in the given input. It returns -1 if there is no match.
Golang bytes.LastIndexAny() function usage example
package main
import (
"fmt"
"bytes"
)
func main() {
str := []byte("abcdefg...xyz")
fmt.Println(bytes.LastIndexAny(str, "xyz"))
fmt.Println(bytes.LastIndexAny(str, "zyx"))
fmt.Println(bytes.LastIndexAny(str, "P"))
fmt.Println(bytes.LastIndexAny(str, ""))
}
Output :
12
12
-1
-1
Reference :
Advertisement
Something interesting
Tutorials
+4.6k Mac OSX : Get disk partitions' size, type and name
+10.1k Golang : Edge detection with Sobel method
+6.5k PHP : Shuffle to display different content or advertisement
+12.3k Golang : How to display image file or expose CSS, JS files from localhost?
+14.4k Android Studio : Use image as AlertDialog title with custom layout example
+5.4k Golang : Return multiple values from function
+20.8k Golang : Underscore or snake_case to camel case example
+4.9k Python : Find out the variable type and determine the type with simple test
+9.6k Javascript : Read/parse JSON data from HTTP response
+26k Golang : Convert IP address string to long ( unsigned 32-bit integer )
+12.8k Swift : Convert (cast) Int or int32 value to CGFloat