Go (RE2)

Generic API Key in GO

Match generic long alphanumeric tokens (32+ chars) typical of API keys and access tokens.

Try it in the GO tester →

Pattern

regexGO
\b[A-Za-z0-9_\-]{32,}\b   (flags: g)

Go (RE2) code

goGo
package main

import (
	"fmt"
	"regexp"
)

func main() {
	re := regexp.MustCompile(`\b[A-Za-z0-9_\-]{32,}\b`)
	input := `sk_test_abcdef0123456789abcdef0123456789abcd`
	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

Word-bounded sequence of 32 or more letters, digits, underscores, or hyphens. Broad by design — pair with context (e.g. api_key=) to reduce false positives.

Examples

Input

sk_test_abcdef0123456789abcdef0123456789abcd

Matches

  • sk_test_abcdef0123456789abcdef0123456789abcd

Input

short

No match

Same pattern, other engines

← Back to Generic API Key overview (all engines)