// 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"(?m)(?<=Project\s+#.*\r?\n?)(?<Item>.+)\s+\r?\n?(?:Total\s+Cost:\s+)(?<TotalCost>[\d.,\$]+)\r?\n?(?:City\s+Obligation:\s+)(?<CityObligation>[\d.,\$]+)\r?\n?(?:Delivery\s+Method:\s+)(?<DeliveryMethod>.+)\r?\n?(?:Cooperating\s+Agencies:\s+)(?<CooperatingAgencies>.+)\r?\n?\r?\n?(?:Special\s+Circumstances)\r?\n?\r?\n?(?<SC>.+)").unwrap();
let string = "Facilities Management
Project #: 0450-CARP
Replace Carpet - City Hall
Total Cost: $243,203
City Obligation: $200,000
Delivery Method: TBD
Cooperating Agencies: None
Special Circumstances
None
Project Description Location: One City Plaza - City Hall
Remove and Replace the carpet at City Hall.
Project Justification
The carpet at City Hall is 18 years old, with some areas failing and causing a trip hazard.
The carpet needs replacement in phases over the next 4-5 years, beginning in Fiscal
Year 20 and ending in Fiscal Year 24.
Budget Impact/Other
Statement of Impact: There is no impact to the City’s operating budget.
Expenditures Previous 2021 2022 2023 2024 2025 Out Total
Years Years
Other $43,203 $50,000 $50,000 $50,000 $50,000 $243,203
Total $43,203 $50,000 $50,000 $50,000 $50,000 $243,203
Funding Previous 2021 2022 2023 2024 2025 Out Total
Sources Years Years
General Fund $43,203 $50,000 $50,000 $50,000 $50,000 $243,203
Total $43,203 $50,000 $50,000 $50,000 $50,000 $243,203
FY 2021 - FY 2025 Capital Improvement Program Page 18 Effective July 1, 2020";
// 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/