package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?P<timestamp>\d{2}\/\d{2}\/\d{4}\s+\d{2}\:\d{2}\:\d{2}\.\d{1,4}\s*\+\d{2}\:\d{2})\s*-\s*\[(?P<severity>[A-Z]+)\]\s*-\s*\[(?P<subsystem>[^\]]+)\]\s*-\s*(?P<message>.*)`)
var str = `01/04/2021 15:29:55.2955 +03:00 - [INFO] - [w3wp/LPAPI-Last Casino/153] - AppsFlyerPostback?re_targeting_conversion_type=&is_retargeting=false&app_id=com.rocketplay.luckyplay&platform=android&event_type=in-app-event&attribution_type=organic&event_time=2021-04-01 12:29:59&event_time_selected_timezone=2021-04-01 05:29:59.349-0700&event_name=app-login&event_value={"":1}¤cy=USD&selected_currency=USD&revenue_in_selected_currency=&cost_per_install=&click_time=&click_time_selected_timezone=&install_time=2021-02-22 15:51:48&install_time_selected_timezone=2021-02-22 07:51:48.419-0800&agency=&media_source=Organic&campaign=&fb_campaign_id=&fb_campaign_name=&fb_adset_name=&fb_adset_id=&fb_adgroup_id=&fb_adgroup_name=&af_siteid=&country_code=US&city=Lady Lake&ip=8.24.83.231&wifi=true&language=English&appsflyer_device_id=1614007442730-8802774993131726691&customer_user_id=&android_id=&imei=&advertising_id=e7f5a367-3a47-43b3-a0d7-34ab582db7f3&mac=&device_brand=google&device_model=Acer Chromebook 15 (CB515-1H, CB515-1HT)&os_version=9&sdk_version=v4.6.0&app_version=5.3.7&operator=&carrier=&af_sub1=&af_sub2=&af_sub3=&af_sub4=&af_sub5=&click_url=&http_referrer=&app_name=Lucky Play Casino – Free Las Vegas Slots Machines&download_time=2021-02-22 15:24:00&download_time_selected_timezone=2021-02-22 07:24:00.000-0800&af_keywords=&bundle_id=com.rocketplay.luckyplay&attributed_touch_type=&attributed_touch_time=
`
if len(re.FindStringIndex(str)) > 0 {
fmt.Println(re.FindString(str),"found at index",re.FindStringIndex(str)[0])
}
}
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/