package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?ms),\s*("subresource_uris":.[^}]*[}])`)
var str = `{
"first_page_uri": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/LastMonth.json?PageSize=1000&Page=0",
"end": 387,
"previous_page_uri": null,
"uri": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/LastMonth.json?PageSize=1000&Page=0",
"page_size": 1000,
"start": 0,
"usage_records": [
{
"category": "wireless-usage",
"description": "SIM Usage",
"account_sid": "ACd7a7c24a3c7b0b0ddcde452fd6c18aae",
"start_date": "2023-01-01",
"end_date": "2023-01-31",
"as_of": "2023-02-05T06:53:40+00:00",
"count": "0",
"count_unit": "units",
"usage": "0",
"usage_unit": "units",
"price": "0",
"price_unit": "usd",
"api_version": "2010-04-01",
"uri": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/LastMonth.json?Category=wireless-usage&StartDate=2023-01-01&EndDate=2023-01-31",
"subresource_uris": {
"all_time": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/AllTime.json?Category=wireless-usage",
"today": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/Today.json?Category=wireless-usage",
"yesterday": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/Yesterday.json?Category=wireless-usage",
"this_month": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/ThisMonth.json?Category=wireless-usage",
"last_month": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/LastMonth.json?Category=wireless-usage",
"daily": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/Daily.json?Category=wireless-usage",
"monthly": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/Monthly.json?Category=wireless-usage",
"yearly": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/Yearly.json?Category=wireless-usage"
}
},
{
"category": "pv-basic-rooms",
"description": "Go Rooms",
"account_sid": "ACd7a7c24a3c7b0b0ddcde452fd6c18aae",
"start_date": "2023-01-01",
"end_date": "2023-01-31",
"as_of": "2023-02-05T06:53:40+00:00",
"count": "0",
"count_unit": "",
"usage": "0",
"usage_unit": "",
"price": "0",
"price_unit": "usd",
"api_version": "2010-04-01",
"uri": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/LastMonth.json?Category=pv-basic-rooms&StartDate=2023-01-01&EndDate=2023-01-31",
"subresource_uris": {
"all_time": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/AllTime.json?Category=pv-basic-rooms",
"today": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/Today.json?Category=pv-basic-rooms",
"yesterday": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/Yesterday.json?Category=pv-basic-rooms",
"this_month": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/ThisMonth.json?Category=pv-basic-rooms",
"last_month": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/LastMonth.json?Category=pv-basic-rooms",
"daily": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/Daily.json?Category=pv-basic-rooms",
"monthly": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/Monthly.json?Category=pv-basic-rooms",
"yearly": "/2010-04-01/Accounts/ACd7a7c24a3c7b0b0ddcde452fd6c18aae/Usage/Records/Yearly.json?Category=pv-basic-rooms"
}
},
`
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/