如何解析golang时间

i have this dates "25th April 2019 01:01 AM"

"11th May 2019 07:28 AM"

"26th August 2019 11:07 AM"

"31st July 2019 01:26 PM"

ETC...

my try

timeStr = strings.Replace(timeStr,"th","",1)
timeStr = strings.Replace(timeStr,"st","",1)
timeStr = strings.Replace(timeStr,"rd","",1)
timeStr = strings.Replace(timeStr,"nd","",1)
time.Parse("2 January 2006 15:04 PM",timeStr)

but this is wrong as it can remove characters from the month

How about this?

if d := timeStr[1]; d >= '0' && d <= '9' {
    // 2-digit day
    timeStr = timeStr[:2] + timeStr[4:]
} else {
    // 1-digit day
    timeStr = timeStr[:1] + timeStr[3:]
}

Can use a regexp to do such kind of things.

re := regexp.MustCompile(`^(\d{1,2})(th|st|rd|nd)`)
re.ReplaceAllString("31st July 2019 01:26 PM", "$1")