Documentation
¶
Index ¶
- type RegexpRegistry
- func (rr *RegexpRegistry) LinkHandler(fh sprout.Handler) error
- func (rr *RegexpRegistry) RegexFind(regex string, value string) (string, error)
- func (rr *RegexpRegistry) RegexFindAll(regex string, value string, n int) ([]string, error)
- func (rr *RegexpRegistry) RegexFindAllGroups(regex string, n int, value string) ([][]string, error)
- func (rr *RegexpRegistry) RegexFindAllNamed(regex string, n int, value string) ([]map[string]string, error)
- func (rr *RegexpRegistry) RegexFindGroups(regex string, value string) ([]string, error)
- func (rr *RegexpRegistry) RegexFindNamed(regex string, value string) (map[string]string, error)
- func (rr *RegexpRegistry) RegexMatch(regex string, value string) (bool, error)
- func (rr *RegexpRegistry) RegexQuoteMeta(value string) string
- func (rr *RegexpRegistry) RegexReplaceAll(regex string, value string, replacedBy string) (string, error)
- func (rr *RegexpRegistry) RegexReplaceAllLiteral(regex string, value string, replacedBy string) (string, error)
- func (rr *RegexpRegistry) RegexSplit(regex string, value string, n int) ([]string, error)
- func (rr *RegexpRegistry) RegisterAliases(aliasesMap sprout.FunctionAliasMap) error
- func (rr *RegexpRegistry) RegisterFunctions(funcsMap sprout.FunctionMap) error
- func (rr *RegexpRegistry) RegisterNotices(notices *[]sprout.FunctionNotice) error
- func (rr *RegexpRegistry) UID() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RegexpRegistry ¶
type RegexpRegistry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *RegexpRegistry
NewRegistry creates a new instance of regexp registry.
func (*RegexpRegistry) LinkHandler ¶
func (rr *RegexpRegistry) LinkHandler(fh sprout.Handler) error
LinkHandler links the handler to the registry at runtime.
func (*RegexpRegistry) RegexFind ¶
func (rr *RegexpRegistry) RegexFind(regex string, value string) (string, error)
RegexFind searches for the first match of a regex pattern in a string and returns it, with error handling.
Parameters:
regex string - the regular expression to search with. value string - the string to search within.
Returns:
string - the first regex match found. error - error if the regex fails to compile.
For an example of this function in a Go template, refer to Sprout Documentation: regexFind.
func (*RegexpRegistry) RegexFindAll ¶
RegexFindAll finds all matches of a regex pattern in a string up to a specified limit, with error handling.
Parameters:
regex string - the regular expression to search with. value string - the string to search within. n int - the maximum number of matches to return; use -1 for no limit.
Returns:
[]string - all regex matches found. error - error if the regex fails to compile.
For an example of this function in a Go template, refer to Sprout Documentation: regexFindAll.
func (*RegexpRegistry) RegexFindAllGroups ¶ added in v1.0.0
RegexFindAllGroups finds all matches of a regex pattern in a string up to a specified limit and returns the matched groups, with error handling.
Parameters:
regex string - the regular expression to search with. value string - the string to search within. n int - the maximum number of matches to return; use -1 for no limit.
Returns:
[][]string - a slice containing the matched groups for each match found. error - error if the regex fails to compile.
For an example of this function in a Go template, refer to Sprout Documentation: regexFindAllGroups.
func (*RegexpRegistry) RegexFindAllNamed ¶ added in v1.0.0
func (rr *RegexpRegistry) RegexFindAllNamed(regex string, n int, value string) ([]map[string]string, error)
RegexFindAllNamed finds all matches of a regex pattern with named capturing groups in a string up to a specified limit and returns a slice of maps of group names to matched strings, with error handling.
Parameters:
regex string - the regular expression to search with, containing named capturing groups. value string - the string to search within. n int - the maximum number of matches to return; use -1 for no limit.
Returns:
[]map[string]string - a slice containing a map of group names to their corresponding matched strings for each match found. error - error if the regex fails to compile.
For an example of this function in a Go template, refer to Sprout Documentation: regexFindAllNamed.
func (*RegexpRegistry) RegexFindGroups ¶ added in v1.0.0
func (rr *RegexpRegistry) RegexFindGroups(regex string, value string) ([]string, error)
RegexFindGroups finds the first match of a regex pattern in a string and returns the matched groups, with error handling.
Parameters:
regex string - the regular expression to search with. value string - the string to search within.
Returns:
[]string - the matched groups from the first regex match found. error - error if the regex fails to compile.
For an example of this function in a Go template, refer to Sprout Documentation: regexFindGroups.
func (*RegexpRegistry) RegexFindNamed ¶ added in v1.0.0
RegexFindNamed finds the first match of a regex pattern with named capturing groups in a string and returns a map of group names to matched strings, with error handling.
Parameters:
regex string - the regular expression to search with, containing named capturing groups. value string - the string to search within.
Returns:
map[string]string - a map of group names to their corresponding matched strings. error - error if the regex fails to compile.
For an example of this function in a Go template, refer to Sprout Documentation: regexFindNamed.
func (*RegexpRegistry) RegexMatch ¶
func (rr *RegexpRegistry) RegexMatch(regex string, value string) (bool, error)
RegexMatch checks if a string matches a regex pattern, with error handling.
Parameters:
regex string - the regular expression to match against. value string - the string to check.
Returns:
bool - true if the string matches the regex pattern, otherwise false. error - error if the regex fails to compile.
For an example of this function in a Go template, refer to Sprout Documentation: regexMatch.
func (*RegexpRegistry) RegexQuoteMeta ¶
func (rr *RegexpRegistry) RegexQuoteMeta(value string) string
RegexQuoteMeta returns a literal pattern string for the provided string.
Parameters:
value string - the string to be escaped.
Returns:
string - the escaped regex pattern.
For an example of this function in a Go template, refer to Sprout Documentation: regexQuoteMeta.
func (*RegexpRegistry) RegexReplaceAll ¶
func (rr *RegexpRegistry) RegexReplaceAll(regex string, value string, replacedBy string) (string, error)
RegexReplaceAll replaces all occurrences of a regex pattern in a string with a replacement string, with error handling.
Parameters:
regex string - the regular expression to replace. value string - the string containing the original text. replacedBy string - the replacement text.
Returns:
string - the modified string after all replacements. error - error if the regex fails to compile.
For an example of this function in a Go template, refer to Sprout Documentation: regexReplaceAll.
func (*RegexpRegistry) RegexReplaceAllLiteral ¶
func (rr *RegexpRegistry) RegexReplaceAllLiteral(regex string, value string, replacedBy string) (string, error)
RegexReplaceAllLiteral replaces all occurrences of a regex pattern in a string with a literal replacement string, with error handling.
Parameters:
regex string - the regular expression to replace. value string - the string containing the original text. replacedBy string - the literal replacement text.
Returns:
string - the modified string after all replacements, treating the replacement text as literal text. error - error if the regex fails to compile.
For an example of this function in a Go template, refer to Sprout Documentation: regexReplaceAllLiteral.
func (*RegexpRegistry) RegexSplit ¶
RegexSplit splits a string by a regex pattern up to a specified number of substrings, with error handling.
Parameters:
regex string - the regular expression to split by. value string - the string to split. n int - the maximum number of substrings to return; use -1 for no limit.
Returns:
[]string - the substrings resulting from the split. error - error if the regex fails to compile.
For an example of this function in a Go template, refer to Sprout Documentation: regexSplit.
func (*RegexpRegistry) RegisterAliases ¶ added in v0.6.0
func (rr *RegexpRegistry) RegisterAliases(aliasesMap sprout.FunctionAliasMap) error
func (*RegexpRegistry) RegisterFunctions ¶
func (rr *RegexpRegistry) RegisterFunctions(funcsMap sprout.FunctionMap) error
RegisterFunctions registers all functions of the registry.
func (*RegexpRegistry) RegisterNotices ¶ added in v0.6.0
func (rr *RegexpRegistry) RegisterNotices(notices *[]sprout.FunctionNotice) error
func (*RegexpRegistry) UID ¶ added in v1.0.0
func (rr *RegexpRegistry) UID() string
UID returns the unique identifier of the registry.