package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)
(?:
^ \d{2} - \d{4} [^|\r\n]* \|
| \G
)
(?: [^|\r\n]* \| )*
\K
[\r\n]+ (?! [\r\n]* (?: ^ \d{2} - \d{4} | $ ) )
`)
var str = `00-1234T|
Data|Commments|
12-3456|Some data|Notes|
65-8436ZZ|Data|
|
45-4576AA|Some data|Comments|
98-4392REV|Data|
|
00-5432|Some Data|Some Comments|
`
var substitution = "#CRLF#"
fmt.Println(re.ReplaceAllString(str, substitution))
}
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/