use strict;
my $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
}';
my $regex = qr/^([a-zA-Z]+)\s*\{(.*?)}(?=\n[a-zA-Z]+\s*{\n|\Z)/msp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html