the big length of input string (my string is a little bigger than 800k symbols)?
str := "somestring \"text\":[`somestring`,] somestring"
reg := regexp.MustCompile("\"text\":\\[`(.*?)`,\\]")
match := reg.FindStringSubmatch(sbody)
fmt.Println(match[1])
This example works correctly, but when I change str with real string with 800k symbols, i have this error
goroutine 1 [running]:
main.main()
Path/to/directory/main.go:24 +0x19f
Process finished with the exit code 2
If i am wrong, what can be cause of this error?
If in this example, with one actual match, this work correctly, why it fail with the big string? So, answer to your question, is more no, than yes I may be wrong
Instead of printing a single element (match[1]), try printing the whole thing fmt.Printf("%v\n", match ). match could be empty or have only 1 element.
Okay this is worst than phantom error. I do some debug, and there really nil in match. I write wrong regex, and I don't know why
Lesson learned to never just use a slice without length checking it first :P
Обсуждают сегодня