package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?ms)^([a-zA-Z]+)\s*\{(.*?)}(?=\n[a-zA-Z]+\s*{\n|\Z)`)
var str = `BackdropNode {
inputs 0
name BackdropNode6
tile_color 0x555555ff
label RDN
note_font_size 42
xpos -1136
ypos -4272
bdwidth 451
bdheight 529
}
Write {
file "\[value project_directory]/_output_/\[string range \[file tail \[value root.name]] 0 20].mov"
colorspace sRGB
raw true
file_type mov\{(.*?)\}
mov64_format "mov (QuickTime / MOV)"
mov64_codec AVdh
mov64_dnxhd_codec_profile "DNxHD 422 8-bit 145Mbit"
mov64_dnxhr_codec_profile "SQ 4:2:2 8-bit"
mov64_pixel_format {{0} "yuv420p\tYCbCr 4:2:0 8-bit"}
mov64_quality High
mov64_advanced 1
mov64_write_timecode true
mov64_gop_size 12
mov64_b_frames 0
mov64_bitrate 20000
mov64_bitrate_tolerance 40000000
mov64_quality_min 2
mov64_quality_max 31
render_order 3
checkHashOnRead false
version 132
in_colorspace scene_linear
out_colorspace scene_linear
name Write2
xpos -1025
ypos 2230
}`
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/