strings

package
v0.0.0-...-473e0bf Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2019 License: GPL-3.0 Imports: 4 Imported by: 7

Documentation

Overview

可以完成针对字符串的高级操作

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DouExstact

func DouExstact(src string, sym string) ([]string, error)

DouExstact 标准截取. 从src中按照指定的sym进行截取sym之间的字符 例如从#ABC#abc#DEF#中截取出 ABC和DEF

Example
src := "#ABC#DEF#HHH#eee"

sub, err := DouExstact(src, "#")
if err != nil {
	log.Fatalln(err)
}

log.Println(sub)
Output:

func DouExstactReplace

func DouExstactReplace(src string, sym string, value map[string]interface{}) (string, error)

DouExstactReplace 标准替换, 从src中按照指定的sym进行提取,并从value中获取相对应的val 替换到指定位置

func RemoveMultipeSpace

func RemoveMultipeSpace(oldStr string) (newStr string)

RemoveMultipeSpace 去除字符串中多余的空格

func ReplaceAscii

func ReplaceAscii(src string, seg []string) string

ReplaceAscii 替换src当中指定的字符串类型的控制字符 例如将 字符串类型的"\n"替换成 Ascii的 10(LF)

func Reverse

func Reverse(src, seg string) string

Reverse 将源字符串按照指定的分隔符进行反转 例如: src = www.mydomain.com.cn dist = cn.com.mydomian.www

func ReverseWithSeg

func ReverseWithSeg(src, oldSeg, newSeg string) string

ReverseWithSeg 将源字符串按照指定的分隔符进行反转,同时使用新分隔符替代旧分隔符 例如: src = www.mydomain.com.cn, newSeg="-" dist = cn-com-mydomian-www

func SymExstact

func SymExstact(src string, sym1, sym2 string) ([]string, error)

SymExstact 对称截取. 从src中截取sym1与sym2之间的字符 例如从{ABC}abc{CHD}中按照'{','}'进行截取,最后会截取到 ABC和CHD

Example
src := "{ABC}abc{DEF}jhi"
sub, err := SymExstact(src, "{", "}")
if err != nil {
	log.Fatalln(err)
}

log.Println(sub)
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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