"Go FindAllIndex()"의 두 판 사이의 차이

14번째 줄: 14번째 줄:
content := []byte("London")
content := []byte("London")
re := regexp.MustCompile(`o.`)
re := regexp.MustCompile(`o.`)
fmt.Println(re.FindAllIndex(content, 1))
fmt.Println(re.FindAllIndex(content, -1))
}
</syntaxhighlight>
<syntaxhighlight lang='go' run>
package main
import (
"fmt"
"regexp"
)
func main() {
content := []byte("paranormal")
re := regexp.MustCompile(`a.`)
fmt.Println(re.FindAllIndex(content, 1))
fmt.Println(re.FindAllIndex(content, 1))
fmt.Println(re.FindAllIndex(content, -1))
fmt.Println(re.FindAllIndex(content, -1))

2023년 1월 26일 (목) 10:28 판

1 개요

Go FindAllIndex()
Go regexp.FindAllIndex()
package main

import (
	"fmt"
	"regexp"
)

func main() {
	content := []byte("London")
	re := regexp.MustCompile(`o.`)
	fmt.Println(re.FindAllIndex(content, 1))
	fmt.Println(re.FindAllIndex(content, -1))
}
package main

import (
	"fmt"
	"regexp"
)

func main() {
	content := []byte("paranormal")
	re := regexp.MustCompile(`a.`)
	fmt.Println(re.FindAllIndex(content, 1))
	fmt.Println(re.FindAllIndex(content, -1))
}
package main

import (
	"fmt"
	"regexp"
)

func main() {
	content := []byte("aaaabbbb")
	re := regexp.MustCompile(`aa.*bb`)
	fmt.Println(re.FindAllIndex(content, 1))
	fmt.Println(re.FindAllIndex(content, -1))
}

2 같이 보기

3 참고

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