新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)GoFrame教程:GoFramegstr-位置查找
Pos

十載的建德網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。營銷型網(wǎng)站的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整建德建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)公司從事“建德網(wǎng)站設(shè)計”,“建德網(wǎng)站推廣”以來,每個客戶項目都認(rèn)真落實執(zhí)行。
- 說明:?
Pos?返回?needle?在haystack中第一次出現(xiàn)的位置,區(qū)分大小寫。 如果沒有找到,則返回-1。 - 格式:
Pos(haystack, needle string, startOffset ...int) int
- 示例:
func ExamplePos() {
var (
haystack = `Hello World`
needle = `World`
result = gstr.Pos(haystack, needle)
)
fmt.Println(result)
// Output:
// 6
}
PosRune
- 說明:?
PosRune?的作用于函數(shù)?Pos?相似,但支持?haystack?和?needle?為?unicode?字符串。 - 格式:
PosRune(haystack, needle string, startOffset ...int) int
- 示例:
func ExamplePosRune() {
var (
haystack = `GOFrame是一款模塊化、高性能、企業(yè)級的Go基礎(chǔ)開發(fā)框架`
needle = `Go`
posI = gstr.PosRune(haystack, needle)
posR = gstr.PosRRune(haystack, needle)
)
fmt.Println(posI)
fmt.Println(posR)
// Output:
// 0
// 22
}
PosI
- 說明:?
PosI?返回?needle?在?haystack?中第一次出現(xiàn)的位置,不區(qū)分大小寫。 如果沒有找到,則返回?-1?。 - 格式:
PosI(haystack, needle string, startOffset ...int) int
- 示例:
func ExamplePosI() {
var (
haystack = `GoFrame is very, very easy to use`
needle = `very`
posI = gstr.PosI(haystack, needle)
posR = gstr.PosR(haystack, needle)
)
fmt.Println(posI)
fmt.Println(posR)
// Output:
// 11
// 17
}
PosRuneI
- 說明:?
PosRuneI?的作用于函數(shù)?PosI?相似,但支持?haystack?和?needle?為?unicode?字符串。 - 格式:
PosIRune(haystack, needle string, startOffset ...int) int
- 示例:
func ExamplePosIRune() {
{
var (
haystack = `GoFrame是一款模塊化、高性能、企業(yè)級的Go基礎(chǔ)開發(fā)框架`
needle = `高性能`
startOffset = 10
result = gstr.PosIRune(haystack, needle, startOffset)
)
fmt.Println(result)
}
{
var (
haystack = `GoFrame是一款模塊化、高性能、企業(yè)級的Go基礎(chǔ)開發(fā)框架`
needle = `高性能`
startOffset = 30
result = gstr.PosIRune(haystack, needle, startOffset)
)
fmt.Println(result)
}
// Output:
// 14
// -1
}
PosR
- 說明:?
PosR?返回?needle?在?haystack?中最后一次出現(xiàn)的位置,區(qū)分大小寫。 如果沒有找到,則返回?-1?。 - 格式:
PosR(haystack, needle string, startOffset ...int) int
- 示例:
func ExamplePosR() {
var (
haystack = `goframe is very, very easy to use`
needle = `very`
posI = gstr.PosI(haystack, needle)
posR = gstr.PosR(haystack, needle)
)
fmt.Println(posI)
fmt.Println(posR)
// Output:
// 11
// 17
}
PosRuneR
- 說明:?
PosRuneR?的作用于函數(shù)?PosR?相似,但支持?haystack?和?needle?為?unicode?字符串。 - 格式:
PosRRune(haystack, needle string, startOffset ...int) int
- 示例:
func ExamplePosRRune() {
var (
haystack = `GoFrame是一款模塊化、高性能、企業(yè)級的Go基礎(chǔ)開發(fā)框架`
needle = `Go`
posI = gstr.PosIRune(haystack, needle)
posR = gstr.PosRRune(haystack, needle)
)
fmt.Println(posI)
fmt.Println(posR)
// Output:
// 0
// 22
}
PosRI
- 說明:?
PosRI?返回?needle?在?haystack?中最后一次出現(xiàn)的位置,不區(qū)分大小寫。 如果沒有找到,則返回?-1?。 - 格式:
PosRI(haystack, needle string, startOffset ...int) int
- 示例:
func ExamplePosRI() {
var (
haystack = `goframe is very, very easy to use`
needle = `VERY`
posI = gstr.PosI(haystack, needle)
posR = gstr.PosRI(haystack, needle)
)
fmt.Println(posI)
fmt.Println(posR)
// Output:
// 11
// 17
}
PosRIRune
- 說明:?
PosRIRune?的作用于函數(shù)?PosRI?相似,但支持?haystack?和?needle?為?unicode?字符串。 - 格式:
PosRIRune(haystack, needle string, startOffset ...int) int
- 示例:
func ExamplePosRIRune() {
var (
haystack = `GoFrame是一款模塊化、高性能、企業(yè)級的Go基礎(chǔ)開發(fā)框架`
needle = `GO`
posI = gstr.PosIRune(haystack, needle)
posR = gstr.PosRIRune(haystack, needle)
)
fmt.Println(posI)
fmt.Println(posR)
// Output:
// 0
// 22
}
文章標(biāo)題:創(chuàng)新互聯(lián)GoFrame教程:GoFramegstr-位置查找
轉(zhuǎn)載源于:http://fisionsoft.com.cn/article/dpoddop.html


咨詢
建站咨詢
