Documentation
¶
Overview ¶
Code generated from UnicodeData-3.0.0.txt for XSD 1.0 regex categories; DO NOT EDIT.
Index ¶
- Constants
- func DefaultMatchTimeout() time.Duration
- func HasBackrefs(pattern string) bool
- func HasCharClassSubtraction(pattern string) bool
- func HasLargeQuantifier(pattern string) bool
- func NormalizeBackrefs(pattern string) string
- func RejectPerlSpecific(pattern string) error
- func SetDefaultMatchTimeout(d time.Duration)
- func Translate(pattern string, dotAll, ignoreCase bool) (string, error)
- func Validate(pattern string, allowBackrefs bool) error
- type Regexp
Constants ¶
const XMLNameCharRange = xmlNameCharRange
const XMLNameStartCharRange = xmlNameStartCharRange
XMLNameStartCharRange / XMLNameCharRange are the XML Name character ranges (for use inside a [...] class), shared with NCName/NMTOKEN validation.
Variables ¶
This section is empty.
Functions ¶
func DefaultMatchTimeout ¶
DefaultMatchTimeout returns the bound on how long the regexp2 backtracking engine spends on a single pattern-facet match before giving up. Patterns that use constructs RE2 cannot handle (character-class subtraction, large quantifiers) compile to regexp2, which is vulnerable to catastrophic backtracking on adversarial inputs; this is a defense-in-depth ceiling for those matches. RE2-compiled patterns are linear-time and unaffected. A value of 0 disables the timeout.
func HasBackrefs ¶
HasBackrefs reports whether the pattern contains a back-reference.
func HasCharClassSubtraction ¶
HasCharClassSubtraction reports whether the pattern uses [a-z-[...]] subtraction.
func HasLargeQuantifier ¶
HasLargeQuantifier reports whether the pattern has a {n,m} bound exceeding RE2's limit.
func NormalizeBackrefs ¶
NormalizeBackrefs rewrites multi-digit back-references for Go's regexp engine.
func RejectPerlSpecific ¶
RejectPerlSpecific rejects Perl-only constructs not allowed in XPath regex.
func SetDefaultMatchTimeout ¶ added in v0.3.0
SetDefaultMatchTimeout sets the default match timeout returned by DefaultMatchTimeout. Setting it to 0 disables the timeout. The change affects only subsequently-compiled patterns. It is safe to call concurrently with regex compilation.
Types ¶
type Regexp ¶
type Regexp struct {
// contains filtered or unexported fields
}
Regexp is a compiled XML Schema pattern-facet regular expression. It matches the whole input value (the pattern is anchored at both ends) against either Go's RE2 engine or, for constructs RE2 lacks, the regexp2 backtracking engine.
func Compile ¶
Compile translates and compiles an XML Schema pattern-facet regular expression, anchoring it so it matches the entire value. Patterns that use XML Schema character-class subtraction ([a-z-[aeiou]]) or quantifier bounds beyond RE2's limit are compiled with the regexp2 backtracking engine, which supports those constructs natively; all other patterns use Go's RE2 engine. It returns an error for patterns that are not valid XML Schema regular expressions, so callers can report a schema error and never silently ignore the facet.
func CompileVersion ¶ added in v0.4.0
CompileVersion is Compile with an XSD 1.1 toggle. In XSD 1.1 mode an unrecognized \p{Is...} block name is accepted (matching every character) per XSD 1.1 test bug 13670. Both versions of the XSD pattern-facet path admit the full XML 1.1 / XML 1.0 5th edition NameChar combining range (U+0300–U+036F, including U+0346) for \c/\C: the U+0346 carve-out belongs to the older XPath-2.0 flavor only (xpath3's Translate, xsdPattern=false), and every XSD pattern facet — 1.0 or 1.1 — follows the 5th-edition NameChar definition (test bug 13606). With xsd11=false the rest of the XSD 1.0 behavior is byte-identical to Compile's original.
func (*Regexp) MatchString ¶
MatchString reports whether the whole string s is matched by the pattern.