package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?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>.+)`)
var str = `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`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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 Golang, please visit: https://golang.org/pkg/regexp/