package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(?:(?:\s{4}|\t)*(?:[^a]t|a[^t]|at[^\s]+)|[^\s]+).*`)
var str = `---------- snippet start ----------
JUnit version 4.11
I.E
Time: 0.015
There was 1 failure:
1) testPerson(PersonTest)
org.junit.ComparisonFailure: expected:<John[1]> but was:<John[]>
a t org.junit.Assert.assertEquals(Assert.java:115)
attention org.junit.Assert.assertEquals(Assert.java:144)
at PersonTest.testPerson(PersonTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
---------- snippet end----------`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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/