parser

package
v0.1.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// IPv4Regexp IPv4正则表达式
	IPv4Regexp = regexp.MustCompile(`(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)){3}`)

	// IPv6Regexp IPv6正则表达式
	// [fF][eE]80:(:[0-9a-fA-F]{1,4}){0,4}(%\w+)?| # IPv6 Link-local
	// ([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}| # IPv6
	// ::([fF]{4}){1}:(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)){3}| # IPv4-mapped IPv6 address
	// (([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?::(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})? # IPv6 with two colons
	IPv6Regexp = regexp.MustCompile(`[fF][eE]80:(:[0-9a-fA-F]{1,4}){0,4}(%\w+)?|([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::([fF]{4}){1}:(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)){3}|(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?::(([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4})?`)
)

Functions

This section is empty.

Types

type Result added in v0.1.4

type Result struct {
	Result []map[string]string `json:"result"`
}

Result 返回解析后的结果

func (*Result) Json added in v0.1.4

func (r *Result) Json(indent bool) string

type Segment

type Segment struct {
	Start   int
	End     int
	Type    string
	Content string
	Result  []string
}

Segment 文本片段

type SorterSegment

type SorterSegment []Segment

SorterSegment 用于对 Segment 进行排序,按照 Start 字段进行排序

func (SorterSegment) Len

func (s SorterSegment) Len() int

func (SorterSegment) Less

func (s SorterSegment) Less(i, j int) bool

func (SorterSegment) Swap

func (s SorterSegment) Swap(i, j int)

type TextParser

type TextParser struct {
	Text           string
	IPv4Fields     []string
	IPv4FillResult func(str string) []string
	IPv6Fields     []string
	IPv6FillResult func(str string) []string
	// contains filtered or unexported fields
}

TextParser 文本解析器

func NewTextParser

func NewTextParser(text string) *TextParser

NewTextParser 初始化文本解析器

func (*TextParser) Json added in v0.1.4

func (p *TextParser) Json(indent bool) string

Json 返回解析后的Json

func (*TextParser) Parse

func (p *TextParser) Parse() *TextParser

Parse 解析文本

func (*TextParser) ParseIPv4

func (p *TextParser) ParseIPv4() *TextParser

ParseIPv4 解析文本中的 IPv4 片段

func (*TextParser) ParseIPv6

func (p *TextParser) ParseIPv6() *TextParser

ParseIPv6 解析文本中的 IPv6 片段

func (*TextParser) String

func (p *TextParser) String() string

String 返回解析后的文本

Jump to

Keyboard shortcuts

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