package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`^(.+?) - (.*)`)
var str = `2016-12-08 10:09:16 - [ERROR] - from application -
! @72aki4439 - Internal server error, for (POST) [/rest/v1/item] ->
play.api.Application$$anon$1: Execution exception[[NullPointerException: null]]
at play.api.Application$class.handleError(Application.scala:296) ~[com.typesafe.play.play_2.11-2.3.8.jar:2.3.8]
at play.api.DefaultApplication.handleError(Application.scala:402) [com.typesafe.play.play_2.11-2.3.8.jar:2.3.8]
Caused by: java.lang.NullPointerException: null
at controllers.RestItem$2.apply(RestItem.java:577) ~[bla-1.0.jar:1.0]`
if len(re.FindStringIndex(str)) > 0 {
fmt.Println(re.FindString(str),"found at index",re.FindStringIndex(str)[0])
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/