re = /(struct\s*\w+.*?(?=fn))(fn.*?(?=\),)\)).*?(?=fn)(fn.*?\))(?=\R\))/
str = '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: =
(
)'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html