Go (RE2)

Unix Timestamp in GO

Match 10-digit Unix timestamps (seconds since epoch) for dates between 2001 and 2286.

Try it in the GO tester →

Pattern

regexGO
\b1[0-9]{9}\b   (flags: g)

Go (RE2) code

goGo
package main

import (
	"fmt"
	"regexp"
)

func main() {
	re := regexp.MustCompile(`\b1[0-9]{9}\b`)
	input := `Created at 1712345678`
	for _, match := range re.FindAllString(input, -1) {
		fmt.Println(match)
	}
}

Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.

How the pattern works

Anchored with word boundaries, matches exactly 10 digits starting with 1 — which covers epoch seconds from roughly 2001-09-09 (1 billion) to 2286.

Examples

Input

Created at 1712345678

Matches

  • 1712345678

Input

1609459200 = 2021-01-01

Matches

  • 1609459200

Input

no timestamps here

No match

Same pattern, other engines

← Back to Unix Timestamp overview (all engines)