Go FindStringIndex()

Jmnote (토론 | 기여)님의 2023년 1월 20일 (금) 14:34 판

1 개요

Go FindStringIndex()
Go regexp.FindStringIndex()
package main

import (
	"fmt"
	"regexp"
)

func main() {
	re := regexp.MustCompile(`ab?`)
	fmt.Println(re.FindStringIndex("tablett"))
	fmt.Println(re.FindStringIndex("foo") == nil)
}
package main

import (
	"fmt"
	"regexp"
)

func main() {
	r, _ := regexp.Compile("p([a-z]+)ch")
	fmt.Println("idx:", r.FindStringIndex("peach punch"))
}

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}