GO语言"strings"包中"LastIndexFunc"函数的用法及代码示例。
用法:
func LastIndexFunc(s string, f func(rune) bool) int
LastIndexFunc 返回满足 f(c) 的最后一个 Unicode 代码点的 s 的索引,如果不满足,则返回 -1。
例子:
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))
}
输出:
5 2 -1
相关用法
- GO LastIndexFunc用法及代码示例
- GO LastIndex用法及代码示例
- GO LastIndexAny用法及代码示例
- GO LastIndexByte用法及代码示例
- GO LeadingZeros32用法及代码示例
- GO Logger.Output用法及代码示例
- GO Log10用法及代码示例
- GO Log用法及代码示例
- GO LeadingZeros8用法及代码示例
- GO LeadingZeros16用法及代码示例
- GO ListenAndServe用法及代码示例
- GO Listener用法及代码示例
- GO Logger用法及代码示例
- GO Len8用法及代码示例
- GO ListenAndServeTLS用法及代码示例
- GO LoadLocation用法及代码示例
- GO Len64用法及代码示例
- GO LoadX509KeyPair用法及代码示例
- GO LookPath用法及代码示例
- GO LookupEnv用法及代码示例
注:本文由纯净天空筛选整理自golang.google.cn大神的英文原创作品 LastIndexFunc。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。