Last active
July 28, 2020 06:09
-
-
Save edp1096/61fae30ca2cd699a82aee571f0c008f1 to your computer and use it in GitHub Desktop.
golang 정규표현식 연습
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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