...

Package templatex

import "github.com/ory/x/templatex"
Overview
Index

Overview ▾

func CompileRegex

func CompileRegex(tpl string, delimiterStart, delimiterEnd byte) (*regexp.Regexp, error)

CompileRegex parses a template and returns a Regexp.

You can define your own delimiters. It is e.g. common to use curly braces {} but I recommend using characters which have no special meaning in Regex, e.g.: <, >

reg, err := templatex.CompileRegex("foo:bar.baz:<[0-9]{2,10}>", '<', '>')
// if err != nil ...
reg.MatchString("foo:bar.baz:123")