textutil

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package textutil provide some extra text handle util

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMatchAll

func IsMatchAll(s string, keywords []string) bool

IsMatchAll keywords in the give text string.

TIP: can use ^ for exclude match.

func ReplaceVars

func ReplaceVars(text string, vars map[string]any, format string) string

ReplaceVars by regex replace given tpl vars.

If format is empty, will use {const defaultVarFormat}

Types

type VarReplacer

type VarReplacer struct {
	Left, Right string
	// contains filtered or unexported fields
}

VarReplacer struct

func NewVarReplacer

func NewVarReplacer(format string) *VarReplacer

NewVarReplacer instance

func (*VarReplacer) Init

func (r *VarReplacer) Init() *VarReplacer

Init var matcher

func (*VarReplacer) Replace

func (r *VarReplacer) Replace(s string, tplVars map[string]any) string

Replace vars in the text contents

func (*VarReplacer) WithFormat

func (r *VarReplacer) WithFormat(format string) *VarReplacer

WithFormat custom var template

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL