// 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)(?<System1>SYSTEM *\n *?TYPE *= )HP(?<System2>.*?FURNACE-HIR +?= [.0-9]+)\n(?<System3>.*?\.\.\n)(?<ZoneName>\".*?\")"#).unwrap();
let string = "\"EL1 Sys1 (PTAC) (G.SSW1)\" = SYSTEM
TYPE = PSZ
HEAT-SOURCE = HEAT-PUMP
ZONE-HEAT-SOURCE = NONE
SIZING-RATIO = 1
COOL-SIZING-RATI = 1
MIN-SUPPLY-T = 58
FAN-SCHEDULE = \"S1 Sys1 (PTAC) Fan Sch\"
CW-LOOP = \"DEFAULT-CW\"
COOLING-CAPACITY = 15752
COOL-SH-CAP = 11839
HP-SUPP-SOURCE = NONE
FURNACE-HIR = 1.24067
CONTROL-ZONE = \"EL1 SSW Perim Zn (G.SSW1)\"
C-EER95 = 8.24
C-COP47 = 0.78
C-AFUE = 0.78
C-SF-MTR-TYPE = 1
C-RF-MTR-TYPE = 1
C-OSA-DMPR-CTRL = 1
C-HTG-DUCT-LOCN = *Ceiling Plenum*
C-HTG-DUCT-RVAL = 7
C-CLG-DUCT-LOCN = *Ceiling Plenum*
C-CLG-DUCT-RVAL = 7
C-CLG-CAP-CATEG = 14
..
\"EL1 SSW Perim Zn (G.SSW1)\" = ZONE
TYPE = CONDITIONED
MIN-FLOW-RATIO = 1
FLOW/AREA = 0.5
OUTSIDE-AIR-FLOW = 96
EXHAUST-FLOW = 80
DESIGN-HEAT-T = 72
HEAT-TEMP-SCH = \"S1 Sys1 (PTAC) Heat Sch\"
DESIGN-COOL-T = 75
COOL-TEMP-SCH = \"S1 Sys1 (PTAC) Cool Sch\"
BASEBOARD-CTRL = THERMOSTATIC
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 SSW Perim Spc (G.SSW1)\"
C-COMPLIANCE-DHW = \"Res Compliance DHW\"
..
\"EL1 SSW Perim Pl Zn (G.SSW38)\" = ZONE
TYPE = UNCONDITIONED
DESIGN-HEAT-T = 72
DESIGN-COOL-T = 81
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 SSW Perim Plnm (G.SSW38)\"
..
\"EL1 Sys1 (PTAC) (G.W2)\" = SYSTEM
TYPE = HP
SIZING-RATIO = 1
COOL-SIZING-RATI = 1
MIN-SUPPLY-T = 58
FAN-SCHEDULE = \"S1 Sys1 (PTAC) Fan Sch\"
CW-LOOP = \"DEFAULT-CW\"
COOLING-CAPACITY = 15752
COOL-SH-CAP = 11839
FURNACE-HIR = 1.24067
HEAT-ELEC-METER = \"Electric Meter 2\"
COOL-ELEC-METER = \"Electric Meter 2\"
C-EER95 = 8.24
C-COP47 = 0.78
C-AFUE = 0.78
C-SF-MTR-TYPE = 1
C-RF-MTR-TYPE = 1
C-OSA-DMPR-CTRL = 1
C-HTG-DUCT-LOCN = *Ceiling Plenum*
C-HTG-DUCT-RVAL = 7
C-CLG-DUCT-LOCN = *Ceiling Plenum*
C-CLG-DUCT-RVAL = 7
C-CLG-CAP-CATEG = 14
..
\"EL1 West Perim Zn (G.W2)\" = ZONE
TYPE = CONDITIONED
MIN-FLOW-RATIO = 1
COOLING-CAPACITY = 15752
COOL-SH-CAP = 11839
BASEBOARD-RATING = -20481.2
FLOW/AREA = 0.5
OUTSIDE-AIR-FLOW = 96
EXHAUST-FLOW = 80
DESIGN-HEAT-T = 72
HEAT-TEMP-SCH = \"S1 Sys1 (PTAC) Heat Sch\"
DESIGN-COOL-T = 75
COOL-TEMP-SCH = \"S1 Sys1 (PTAC) Cool Sch\"
BASEBOARD-CTRL = THERMOSTATIC
SIZING-OPTION = ADJUST-LOADS
CW-LOOP = \"DEFAULT-CW\"
SPACE = \"EL1 West Perim Spc (G.W2)\"
C-COMPLIANCE-DHW = \"Res Compliance DHW\"
..
\"EL1 West Perim Pl Zn (G.W39)\" = ZONE
TYPE = UNCONDITIONED
DESIGN-HEAT-T = 72
DESIGN-COOL-T = 81
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 West Perim Plnm (G.W39)\"
..
\"EL1 Sys1 (PTAC) (G.W3)\" = SYSTEM
TYPE = HP
SIZING-RATIO = 1
COOL-SIZING-RATI = 1
MIN-SUPPLY-T = 58
FAN-SCHEDULE = \"S1 Sys1 (PTAC) Fan Sch\"
CW-LOOP = \"DEFAULT-CW\"
COOLING-CAPACITY = 15752
COOL-SH-CAP = 11839
FURNACE-HIR = 1.24067
HEAT-ELEC-METER = \"Electric Meter 2\"
COOL-ELEC-METER = \"Electric Meter 2\"
C-EER95 = 8.24
C-COP47 = 0.78
C-AFUE = 0.78
C-SF-MTR-TYPE = 1
C-RF-MTR-TYPE = 1
C-OSA-DMPR-CTRL = 1
C-HTG-DUCT-LOCN = *Ceiling Plenum*
C-HTG-DUCT-RVAL = 7
C-CLG-DUCT-LOCN = *Ceiling Plenum*
C-CLG-DUCT-RVAL = 7
C-CLG-CAP-CATEG = 14
..
\"EL1 West Perim Zn (G.W3)\" = ZONE
TYPE = CONDITIONED
MIN-FLOW-RATIO = 1
BASEBOARD-RATING = -20778.4
FLOW/AREA = 0.5
OUTSIDE-AIR-FLOW = 96
EXHAUST-FLOW = 80
DESIGN-HEAT-T = 72
HEAT-TEMP-SCH = \"S1 Sys1 (PTAC) Heat Sch\"
DESIGN-COOL-T = 75
COOL-TEMP-SCH = \"S1 Sys1 (PTAC) Cool Sch\"
BASEBOARD-CTRL = THERMOSTATIC
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 West Perim Spc (G.W3)\"
C-COMPLIANCE-DHW = \"Res Compliance DHW\"
..
\"EL1 West Perim Pl Zn (G.W40)\" = ZONE
TYPE = UNCONDITIONED
DESIGN-HEAT-T = 72
DESIGN-COOL-T = 81
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 West Perim Plnm (G.W40)\"
..
\"EL1 Sys1 (PTAC) (G.W4)\" = SYSTEM
TYPE = HP
SIZING-RATIO = 1
COOL-SIZING-RATI = 1
MIN-SUPPLY-T = 58
FAN-SCHEDULE = \"S1 Sys1 (PTAC) Fan Sch\"
CW-LOOP = \"DEFAULT-CW\"
COOLING-CAPACITY = 15752
COOL-SH-CAP = 11839
FURNACE-HIR = 1.24067
HEAT-ELEC-METER = \"Electric Meter 2\"
COOL-ELEC-METER = \"Electric Meter 2\"
C-EER95 = 8.24
C-COP47 = 0.78
C-AFUE = 0.78
C-SF-MTR-TYPE = 1
C-RF-MTR-TYPE = 1
C-OSA-DMPR-CTRL = 1
C-HTG-DUCT-LOCN = *Ceiling Plenum*
C-HTG-DUCT-RVAL = 7
C-CLG-DUCT-LOCN = *Ceiling Plenum*
C-CLG-DUCT-RVAL = 7
C-CLG-CAP-CATEG = 14
..
\"EL1 West Perim Zn (G.W4)\" = ZONE
TYPE = CONDITIONED
MIN-FLOW-RATIO = 1
BASEBOARD-RATING = -20671
FLOW/AREA = 0.5
OUTSIDE-AIR-FLOW = 96
EXHAUST-FLOW = 80
DESIGN-HEAT-T = 72
HEAT-TEMP-SCH = \"S1 Sys1 (PTAC) Heat Sch\"
DESIGN-COOL-T = 75
COOL-TEMP-SCH = \"S1 Sys1 (PTAC) Cool Sch\"
BASEBOARD-CTRL = THERMOSTATIC
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 West Perim Spc (G.W4)\"
C-COMPLIANCE-DHW = \"Res Compliance DHW\"
..
\"EL1 West Perim Pl Zn (G.W41)\" = ZONE
TYPE = UNCONDITIONED
DESIGN-HEAT-T = 72
DESIGN-COOL-T = 81
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 West Perim Plnm (G.W41)\"
..
\"EL1 Sys1 (PTAC) (G.W5)\" = SYSTEM
TYPE = HP
SIZING-RATIO = 1
COOL-SIZING-RATI = 1
MIN-SUPPLY-T = 58
FAN-SCHEDULE = \"S1 Sys1 (PTAC) Fan Sch\"
CW-LOOP = \"DEFAULT-CW\"
COOLING-CAPACITY = 15752
COOL-SH-CAP = 11839
FURNACE-HIR = 1.24067
HEAT-ELEC-METER = \"Electric Meter 2\"
COOL-ELEC-METER = \"Electric Meter 2\"
C-EER95 = 8.24
C-COP47 = 0.78
C-AFUE = 0.78
C-SF-MTR-TYPE = 1
C-RF-MTR-TYPE = 1
C-OSA-DMPR-CTRL = 1
C-HTG-DUCT-LOCN = *Ceiling Plenum*
C-HTG-DUCT-RVAL = 7
C-CLG-DUCT-LOCN = *Ceiling Plenum*
C-CLG-DUCT-RVAL = 7
C-CLG-CAP-CATEG = 14
..
\"EL1 West Perim Zn (G.W5)\" = ZONE
TYPE = CONDITIONED
MIN-FLOW-RATIO = 1
BASEBOARD-RATING = -20649.5
FLOW/AREA = 0.5
OUTSIDE-AIR-FLOW = 96
EXHAUST-FLOW = 80
DESIGN-HEAT-T = 72
HEAT-TEMP-SCH = \"S1 Sys1 (PTAC) Heat Sch\"
DESIGN-COOL-T = 75
COOL-TEMP-SCH = \"S1 Sys1 (PTAC) Cool Sch\"
BASEBOARD-CTRL = THERMOSTATIC
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 West Perim Spc (G.W5)\"
C-COMPLIANCE-DHW = \"Res Compliance DHW\"
..
\"EL1 West Perim Pl Zn (G.W42)\" = ZONE
TYPE = UNCONDITIONED
DESIGN-HEAT-T = 72
DESIGN-COOL-T = 81
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 West Perim Plnm (G.W42)\"
..
\"EL1 Sys1 (PTAC) (G.W6)\" = SYSTEM
TYPE = HP
SIZING-RATIO = 1
COOL-SIZING-RATI = 1
MIN-SUPPLY-T = 58
FAN-SCHEDULE = \"S1 Sys1 (PTAC) Fan Sch\"
CW-LOOP = \"DEFAULT-CW\"
COOLING-CAPACITY = 15752
COOL-SH-CAP = 11839
FURNACE-HIR = 1.24067
HEAT-ELEC-METER = \"Electric Meter 2\"
COOL-ELEC-METER = \"Electric Meter 2\"
C-EER95 = 8.24
C-COP47 = 0.78
C-AFUE = 0.78
C-SF-MTR-TYPE = 1
C-RF-MTR-TYPE = 1
C-OSA-DMPR-CTRL = 1
C-HTG-DUCT-LOCN = *Ceiling Plenum*
C-HTG-DUCT-RVAL = 7
C-CLG-DUCT-LOCN = *Ceiling Plenum*
C-CLG-DUCT-RVAL = 7
C-CLG-CAP-CATEG = 14
..
\"EL1 West Perim Zn (G.W6)\" = ZONE
TYPE = CONDITIONED
MIN-FLOW-RATIO = 1
BASEBOARD-RATING = -20499.1
FLOW/AREA = 0.5
OUTSIDE-AIR-FLOW = 96
EXHAUST-FLOW = 80
DESIGN-HEAT-T = 72
HEAT-TEMP-SCH = \"S1 Sys1 (PTAC) Heat Sch\"
DESIGN-COOL-T = 75
COOL-TEMP-SCH = \"S1 Sys1 (PTAC) Cool Sch\"
BASEBOARD-CTRL = THERMOSTATIC
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 West Perim Spc (G.W6)\"
C-COMPLIANCE-DHW = \"Res Compliance DHW\"
..
\"EL1 West Perim Pl Zn (G.W43)\" = ZONE
TYPE = UNCONDITIONED
DESIGN-HEAT-T = 72
DESIGN-COOL-T = 81
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 West Perim Plnm (G.W43)\"
..
\"EL1 Sys1 (PTAC) (G.W7)\" = SYSTEM
TYPE = HP
SIZING-RATIO = 1
COOL-SIZING-RATI = 1
MIN-SUPPLY-T = 58
FAN-SCHEDULE = \"S1 Sys1 (PTAC) Fan Sch\"
CW-LOOP = \"DEFAULT-CW\"
COOLING-CAPACITY = 15752
COOL-SH-CAP = 11839
FURNACE-HIR = 1.24067
HEAT-ELEC-METER = \"Electric Meter 2\"
COOL-ELEC-METER = \"Electric Meter 2\"
C-EER95 = 8.24
C-COP47 = 0.78
C-AFUE = 0.78
C-SF-MTR-TYPE = 1
C-RF-MTR-TYPE = 1
C-OSA-DMPR-CTRL = 1
C-HTG-DUCT-LOCN = *Ceiling Plenum*
C-HTG-DUCT-RVAL = 7
C-CLG-DUCT-LOCN = *Ceiling Plenum*
C-CLG-DUCT-RVAL = 7
C-CLG-CAP-CATEG = 14
..
\"EL1 West Perim Zn (G.W7)\" = ZONE
TYPE = CONDITIONED
MIN-FLOW-RATIO = 1
BASEBOARD-RATING = -20649.5
FLOW/AREA = 0.5
OUTSIDE-AIR-FLOW = 96
EXHAUST-FLOW = 80
DESIGN-HEAT-T = 72
HEAT-TEMP-SCH = \"S1 Sys1 (PTAC) Heat Sch\"
DESIGN-COOL-T = 75
COOL-TEMP-SCH = \"S1 Sys1 (PTAC) Cool Sch\"
BASEBOARD-CTRL = THERMOSTATIC
SIZING-OPTION = ADJUST-LOADS
SPACE = \"EL1 West Perim Spc (G.W7)\"
C-COMPLIANCE-DHW = \"Res Compliance DHW\"
..";
let substitution = "${System1}PSZ${System2}\\n CONTROL-ZONE = ${ZoneName}\\n${System3}${ZoneName}";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
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/