How to check if date (YYYY-MM-DD) exist in string using regular expression in Go

1 Answer

0 votes
package main

import (
	"fmt"
	"regexp"
)

func main() {
	s := "go java 2020-08-23 php"

	re := regexp.MustCompile(`\d{4}-\d{2}-\d{2}`)

	fmt.Println(re.MatchString(s)) 
}



/*
run:

true

*/

 



answered Aug 23, 2020 by avibootz

Related questions

1 answer 152 views
1 answer 134 views
1 answer 146 views
...