Last active
January 6, 2023 08:18
-
-
Save MangKyu/8205f167f811249388ce42ea402afefd to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"fmt" | |
"regexp" | |
"strings" | |
) | |
var pattern = `^\[[0-9a-fA-F]{32}\][[:space:]][0-9]{4}-[0-9]{2}-[0-9]{2}[[:space:]][0-9]{2}:[0-9]{2}:[0-9]{2}[[:space:]]\[` | |
var content = `[42744e73aebe5366cf627e8cf71c3da6] 2022-12-29 17:31:43 [DEBUG](GetProductService :118) 안녕하세요 이것은 테스트용 문장입니다. | |
multiline이 어디까지 적용되나 확인중입니다. | |
개행을 하겠습니다. | |
[bacd4e73aebe5366cf627e8cf71c3da6] 2022-12-29 17:31:43 [DEBUG](GetProductService :118) 안녕하세요 이것은 테스트용 문장입니다. | |
multiline이 어디까지 적용되나 확인중입니다.` | |
func main() { | |
regex, err := regexp.Compile(pattern) | |
if err != nil { | |
fmt.Println("Failed to compile pattern: ", err) | |
return | |
} | |
lines := strings.Split(content, "\n") | |
fmt.Printf("newLine\tline\n") | |
for _, line := range lines { | |
matches := regex.MatchString(line) | |
fmt.Printf("%v\t%v\n", matches, line) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment