Skip to main content

Posts

Showing posts from March, 2023

Extract date of string using go programming

   import ( "regexp" "fmt" ) func main () { exactDate () } func exactDate () { str1 := "If I am 20 years 10 months and 14 days old as of August 17,2016 then my DOB would be 1995-10-03" re := regexp. MustCompile ( `\d{4}-\d{2}-\d{2}` ) b := re. MatchString (str1) if b { val := re. FindAllString (str1, 1 ) fmt. Println (val[ 0 ]) } } more details