package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?si)^NoticeText:(?:(?!\nNoticeText:).)*\n\s+EventInfo(?:(?!\nNoticeText:).)*
\n\s+Text\s*\[str\]\s*=\s*"([^"]*)"(?:(?!\nNoticeText:).)*\nNoticeText:(?:(?!\nNoticeText:).)*\n\s+EventInfo(?:(?!\nNoticeText:).)*
\n\s+Text\s*\[str\]\s*=\s*"([^"]*)"(?:(?!\nNoticeText:).)*`)
var str = `NoticeText:
NoticeType [str] = USER_TYPING_ON
Text [str] = "user is typing"
EventInfo:
PartyId [int] = 2
EventType [str] = MESSAGE
UserNickname [str] = "Michael"
EventId [int] = 4
Text [str] = "Hey, how are you?"
MsgCheck [str] = NONE
TimeOffset [int] = 23
UserType [str] = AGENT
NoticeText:
NoticeType [str] = USER_TYPING_ON
EventInfo:
PartyId [int] = 1
EventType [str] = MESSAGE
UserNickname [str] = "Bob Smith"
EventId [int] = 6
Text [str] = "I'm good, how are you?"
MsgCheck [str] = NONE
TimeOffset [int] = 28
UserType [str] = CLIENT
MessageType [str] = "text"`
var substitution = "$1"
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/