Skip to content

Instantly share code, notes, and snippets.

@Shibe
Created June 30, 2017 13:46
Show Gist options
  • Save Shibe/bac860d19334266abbee0752d7f1b001 to your computer and use it in GitHub Desktop.
Save Shibe/bac860d19334266abbee0752d7f1b001 to your computer and use it in GitHub Desktop.
package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(\b(0?[1-9]|[12]\d|30|31)[^\w\d\r\n:](0?[1-9]|1[0-2])[^\w\d\r\n:](\d{4}|\d{2})\b)|(\b(0?[1-9]|1[0-2])[^\w\d\r\n:](0?[1-9]|[12]\d|30|31)[^\w\d\r\n:](\d{4}|\d{2})\b)
`)
var str = `14-3-17`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment