use strict;
my $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';
my $regex = qr/(?<=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>.+)/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html