Documentation ¶
Overview ¶
Package textutil provides utility routines for working with text, in particular utf8 encoded text.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
BytesToString returns a string with the supplied byte slice as its contents. The original byte slice must never be modified. Taken from strings.Builder.String().
func ReverseBytes ¶
ReverseBytes returns a new slice containing the runes in the input string in reverse order.
func ReverseString ¶
ReverseString is like ReverseBytes but returns a string.
func StringToBytes ¶
StringToBytes returns the byte slice containing the data for the supplied string without any allocations or copies. It should only be used when the resulting byte slice will never be modified. See https://groups.google.com/g/golang-nuts/c/Zsfk-VMd_fU/m/O1ru4fO-BgAJ
Types ¶
type RewriteRule ¶
RewriteRule represents a rewrite rule of the form s/<match>/<replace>/ or s%<match>%<replace>%. Separators can be escpaed using a \.
func NewRewriteRule ¶
func NewRewriteRule(rule string) (RewriteRule, error)
NewReplacement accepts a string of the form s/<match-re>/<replacement>/ or s%<match-re>%<replacement>% and returns a RewriteRule that can be used to perform the rewquested rewrite. Separators can be escpaed using a \.
func (RewriteRule) MatchString ¶
func (rr RewriteRule) MatchString(input string) bool
Match applies regexp.MatchString.
func (RewriteRule) ReplaceAllString ¶
func (rr RewriteRule) ReplaceAllString(input string) string
ReplaceAllString(input string) applies regexp.ReplaceAllString.
type RewriteRules ¶ added in v0.0.11
type RewriteRules []RewriteRule
func NewRewriteRules ¶ added in v0.0.11
func NewRewriteRules(rules ...string) (RewriteRules, error)
func (RewriteRules) ReplaceAllStringFirst ¶ added in v0.0.11
func (rw RewriteRules) ReplaceAllStringFirst(input string) string