// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?ms)^([a-zA-Z]+)\s*\{(.*?)}(?=\n[a-zA-Z]+\s*{\n|\Z)").unwrap();
let string = "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
}";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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 Rust, please visit: https://docs.rs/regex/latest/regex/