grep

package
v0.0.0-...-83feed8 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: MIT Imports: 4 Imported by: 0

README

Grep

从文本或文件中按行查找符合匹配的字符串

定义

func GrepFromReader(r io.Reader, regstr string) (lines []string, err error)
func GrepFromFile(filestr, regstr string) (lines []string, err error) 

样例

	r := strings.NewReader("a=c\nadmin_monitor_listen_port = 12345\nadmin_monitor_listen_addr=addr")
	lines, err := GrepFromReader(r, "^(admin_monitor_\\S+)[^=]*=\\s*(\\S+)$")
	lines, err := GrepFromFile("/tmp/testgrep", "^(admin_monitor_\\S+)[^=]*=\\s*(\\S+)$")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GrepFromFile

func GrepFromFile(filestr, regstr string) (lines []string, err error)

func GrepFromReader

func GrepFromReader(r io.Reader, regstr string) (lines []string, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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