Documentation
¶
Overview ¶
Package regex provides shared ECMAScript matching and string replacement. It is optional: importing Commons or Data Masking alone does not load it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
Options configures matching limits. Zero values use the engine defaults: no timeout and a 100,000-entry backtracking stack. A negative stack size removes that bound; a negative timeout is invalid.
type Regexp ¶
type Regexp struct {
// contains filtered or unexported fields
}
Regexp is safe for concurrent use. Stateful replacements serialize access to lastIndex; stateless MatchString calls can run concurrently. Do not copy it.
func Compile ¶
Compile accepts ECMAScript d, g, i, m, s, u and y flags. The d flag has no effect on string replacement. Unicode set syntax (v) is not supported.
func (*Regexp) LastIndex ¶
LastIndex returns the UTF-16 offset used by sticky, non-global replacement.
func (*Regexp) MatchString ¶
MatchString searches from the beginning without reading or changing lastIndex. A sticky pattern must match at the beginning.
func (*Regexp) Replace ¶
Replace implements JavaScript string replacement tokens and global/sticky state. Lone UTF-16 surrogates are preserved as WTF-8 bytes in Go strings; encoding/json cannot preserve those bytes as JavaScript string code units.
func (*Regexp) Replacer ¶
Replacer binds a replacement format for use with datamasking.Rule.Replace. The returned callback shares this Regexp's lastIndex.
func (*Regexp) SetLastIndex ¶
SetLastIndex sets an integer UTF-16 offset. Negative values are normalized to zero when used by replacement, as with JavaScript's ToLength operation.