// 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"(?s)(struct\s*\w+.*?(?=fn))(fn.*?(?=\),)\)).*?(?=fn)(fn.*?\))(?=\R\))").unwrap();
let string = "struct mbuh
(
lineshg = 0,
tres = \"text\",
fn track all:#() =
(
local c -- clone
local lpoint = [0,0,0] -- previous point created
local ccoll = #() -- array for created objects
local prev = [0,0] -- var for alt distance changing
),
fn listzfun trs:123 x:#() =
(
obj = snapshotasmesh a
min_vz = max_vz = in coordsys world (getvert obj 1).z
min_vx = max_vx = in coordsys world (getvert obj 1).x
min_vy = max_vy = in coordsys world (getvert obj 1).y
)
)
struct mbuh
(
lineshg = 0,
tres = \"text\",
fn track all:#() =
(
local c -- clone
local lpoint = [0,0,0] -- previous point created
local ccoll = #() -- array for created objects
local prev = [0,0] -- var for alt distance changing
),
fn listzfun trs:123 x:#() =
(
obj = snapshotasmesh a
min_vz = max_vz = in coordsys world (getvert obj 1).z
min_vx = max_vx = in coordsys world (getvert obj 1).x
min_vy = max_vy = in coordsys world (getvert obj 1).y
)
)
fn brung man: =
(
)";
// 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/