Skip to content

Instantly share code, notes, and snippets.

@edp1096
Last active July 28, 2020 06:09
Show Gist options
  • Select an option

  • Save edp1096/61fae30ca2cd699a82aee571f0c008f1 to your computer and use it in GitHub Desktop.

Select an option

Save edp1096/61fae30ca2cd699a82aee571f0c008f1 to your computer and use it in GitHub Desktop.
golang 정규표현식 연습
package main // import "hello-regexp"
import (
"fmt"
"regexp"
"strings"
)
func main() {
targetText := []string{
"abhello world",
"cdipsum lorem",
"efsimply dummy",
"efsimply dummy hahaha",
}
searchText := map[string]string{
"ab": "^ab",
"hello": "hello",
"cd": "^CD|^ab|^efs",
"ef": "ef",
"mmy": "mmy$",
}
for _, t := range targetText {
for k, s := range searchText {
matched, _ := regexp.MatchString(strings.ToLower(s), strings.ToLower(t))
if matched {
fmt.Println(matched, k, t)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment