Documentation
¶
Index ¶
- func Contains(s []string, e string) bool
- func GetFieldByRegex(regex, data string, fields []string) (results map[string]string, err error)
- func GroupWithMultipleRegex(j1 string, j2 string, key string, data string) ([]string, error)
- func GroupWithRegexFilter(j string, fields []string, first int, last int, data string) ([]string, error)
- func IndentSection2(txt string) []string
- func InitializeStruct(t reflect.Type, v reflect.Value)
- func RegexSplit(re string, text string) []string
- type Splitter
- type SplitterResult
- func (s SplitterResult) Cell(index int, field string) (string, error)
- func (s SplitterResult) CombinKey(keys []string) ([]string, error)
- func (s SplitterResult) ConcatString(fields []string, first int, offset int, key string) ([]string, error)
- func (s SplitterResult) Dump(m map[string]string, count int, t reflect.Type) (interface{}, error)
- func (s SplitterResult) Filter(fields []string, first int, offset int) ([]string, error)
- func (s SplitterResult) GroupWith(other *SplitterResult, key string) ([]string, error)
- func (s SplitterResult) GroupWithCombinKey(other *SplitterResult, leftKey []string, rightKey []string) ([]string, error)
- func (sp *SplitterResult) Iterator() *SplitterResultIterator
- func (s SplitterResult) Json() ([]byte, error)
- func (s SplitterResult) Len() int
- func (s SplitterResult) MapToFields(m map[string]string, count int) (interface{}, error)
- func (s SplitterResult) One() (map[string]string, bool)
- func (sp SplitterResult) Projection(multipleField []string, sep string, pairFields [][]string) (map[string]string, error)
- func (s SplitterResult) RowJson(index int) ([]byte, error)
- type SplitterResultIterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFieldByRegex ¶
func GroupWithMultipleRegex ¶
func GroupWithRegexFilter ¶
func GroupWithRegexFilter(j string, fields []string, first int, last int, data string) ([]string, error)
从json字串中提取Splitter,
func IndentSection2 ¶
func RegexSplit ¶
Types ¶
type Splitter ¶
type Splitter struct {
Regex string `json:"regex"`
Name string `json:"name"`
Flags string `json:"flags"`
Pcre bool `json:"pcre"`
// contains filtered or unexported fields
}
func NewSplitterFromJson ¶
func (Splitter) PCRERevert ¶
func TestPCRERegexp(t *testing.T) {
type SplitterResult ¶
type SplitterResult struct {
// 与Python版本的attr类似,指定保持到结果的字段名称
Attr []string
Result []map[string]string
}
func IndentSection ¶
func IndentSection(txt string) *SplitterResult
func SplitterProcessOneTime ¶
func SplitterProcessOneTime(m map[string]string, data string) (*SplitterResult, error)
func (SplitterResult) Cell ¶
func (s SplitterResult) Cell(index int, field string) (string, error)
获取正则匹配结果的指定Cell
func (SplitterResult) CombinKey ¶
func (s SplitterResult) CombinKey(keys []string) ([]string, error)
按照多个key的组合进行分组 返回分组后__match__组成的字符串列表,在返回结果中并不包含分组字段的相关信息,纯粹就是一个聚合功能,用于后续继续处理
func (SplitterResult) ConcatString ¶
func (s SplitterResult) ConcatString(fields []string, first int, offset int, key string) ([]string, error)
主要用于文本的预处理,将匹配结果以给定关键字为key,进行拼接 如果fields字段为nil或长度为0,则用__match__进行拼接,否则用fields包含的字段进行拼接 first和offset同时为-1时,表示在所有结果中进行拼接 first为负,表示从末尾开始计数,-1表示最后,相当与last(s.Result)-1,first = len(s.Result) + first offset为-1时,表示从first直到s.Result的末尾 注意:最终数据以各关键字在文本中出现的先后为顺序
func (SplitterResult) Filter ¶
主要用于文本的预处理 如果fields字段为nil或长度为0,则用__match__进行拼接,否则用fields包含的字段进行拼接 first和offset同时为-1时,表示在所有结果中进行拼接 first为负,表示从末尾开始计数,-1表示最后,相当与last(s.Result)-1,first = len(s.Result) + first offset为-1时,表示从first直到s.Result的末尾
func (SplitterResult) GroupWith ¶
func (s SplitterResult) GroupWith(other *SplitterResult, key string) ([]string, error)
将两个匹配结果集进行组合,主要用于文本预处理场景,用于将两个匹配结果进行拼接 拼接的方法: 1.只有包含了关键字字段的结果才能进行拼接 2.拼接保持了s中的顺序
func (SplitterResult) GroupWithCombinKey ¶
func (s SplitterResult) GroupWithCombinKey(other *SplitterResult, leftKey []string, rightKey []string) ([]string, error)
将两个匹配结果集进行组合,主要用于文本预处理场景,用于将两个匹配结果进行拼接 拼接的方法: 1.只有包含了关键字字段的结果才能进行拼接, 2.拼接保持了s中的顺序
func (*SplitterResult) Iterator ¶
func (sp *SplitterResult) Iterator() *SplitterResultIterator
func (SplitterResult) Len ¶
func (s SplitterResult) Len() int
func (SplitterResult) MapToFields ¶
func (s SplitterResult) MapToFields(m map[string]string, count int) (interface{}, error)
从分割结果中取出COUNT行,如果有需要,还可以将原来结果中的字段,映射为指定字段
func (SplitterResult) Projection ¶
func (sp SplitterResult) Projection(multipleField []string, sep string, pairFields [][]string) (map[string]string, error)
set security nat source rule-set OUT_TO_IN_DY_RULESET rule out_to_in_rule1 match destination-address 20.1.2.2/32 set security nat source rule-set OUT_TO_IN_DY_RULESET rule out_to_in_rule1 then source-nat interface set security nat source rule-set OUT_TO_IN_DY_RULESET rule out_to_in_rule2 match destination-address 172.20.2.10/32 set security nat source rule-set OUT_TO_IN_DY_RULESET rule out_to_in_rule2 match destination-port 1234 to 2222 set security nat source rule-set OUT_TO_IN_DY_RULESET rule out_to_in_rule2 match destination-port 3333 to 3335 set security nat source rule-set OUT_TO_IN_DY_RULESET rule out_to_in_rule2 then source-nat interface multipleField字段定义的数据,将进行拼接,比如: dport=1234-2222 dport=3333-3335,最终返回{dport: "1234-2222,3333-3335"} 不在multipleField中的字段,返回最后的不为空的值,比如:[{"name": "testName"}, {"name": ""}],返回{"name": "testName"}
type SplitterResultIterator ¶
type SplitterResultIterator struct {
// contains filtered or unexported fields
}
func (*SplitterResultIterator) HasNext ¶
func (it *SplitterResultIterator) HasNext() bool