package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(object)|(: .*)$|^(end)$|^(?! On)( .*)`)
var str = `object field: TMemo
Left = 6
Top = 23
Width = 390
Height = 156
Anchors = [akLeft, akTop, akRight, akBottom]
ScrollBars = ssVertical
TabOrder = 1
OnChange = fieldChange
OnKeyUp = fieldKeyUp
AddMenu = True
RightClickMoveCaret = True
RightEdge = 0
end
object btn: TButton
Left = 5
Top = 3
Width = 89
Height = 21
Caption = 'Button'
TabOrder = 0
TabStop = False
OnClick = btnClick
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/