您好,登錄后才能下訂單哦!
func NewReplacer(oldnew ...string) *Replacer //構(gòu)造函數(shù),不定參數(shù),參數(shù)格式為old1,new1,old2,new2,old3,new3......表示old1會(huì)被替換為new1,old2會(huì)被替換為new2...
func (r *Replacer) Replace(s string) string //進(jìn)行替換 返回新的字符串
func (r *Replacer) WriteString(w io.Writer, s string) (n int, err error) //替換后并寫入io.Writer
其他和bytes包類似功能的方法:
字符串和字符串的關(guān)系(逐字節(jié)比較,相等,相似,包含,出現(xiàn)的位置,包含次數(shù),是否是前綴后綴)
func Compare(a, b string) int
func EqualFold(s, t string) bool
func Contains(s, substr string) bool
func Index(s, sep string) int
func LastIndex(s, sep string) int
func Count(s, sep string) int
func HasPrefix(s, prefix string) bool
func HasSuffix(s, suffix string) bool
字符串和字符串的關(guān)系(是否包含串里任何一個(gè)rune以及在字符串中的位置)
func ContainsAny(s, chars string) bool
func IndexAny(s, chars string) int
func LastIndexAny(s, chars string) int
字符串和rune的關(guān)系(包含,轉(zhuǎn)換)
func ContainsRune(s string, r rune) bool
func IndexFunc(s string, f func(rune) bool) int
func IndexRune(s string, r rune) int
func LastIndexFunc(s string, f func(rune) bool) int
字符數(shù)組和字節(jié)的關(guān)系(位置,)
func IndexByte(s string, c byte) int
func LastIndexByte(s string, c byte) int
操作字符串(使用空格或者符合條件的rune分割分組,將分組連接成字符串,分割,大小寫轉(zhuǎn)換,修剪兩端,按規(guī)則修改包含的每個(gè)rune,重復(fù),替換)
func Fields(s string) []string
func FieldsFunc(s string, f func(rune) bool) []string
func Join(a []string, sep string) string
func Split(s, sep string) []string
func SplitAfter(s, sep string) []string
func SplitAfterN(s, sep string, n int) []string
func SplitN(s, sep string, n int) []string
func Title(s string) string
func ToLower(s string) string
func ToLowerSpecial(c unicode.SpecialCase, s string) string
func ToTitle(s string) string
func ToTitleSpecial(c unicode.SpecialCase, s string) string
func ToUpper(s string) string
func ToUpperSpecial(c unicode.SpecialCase, s string) string
func Trim(s string, cutset string) string
func TrimFunc(s string, f func(rune) bool) string
func TrimLeft(s string, cutset string) string
func TrimLeftFunc(s string, f func(rune) bool) string
func TrimPrefix(s, prefix string) string
func TrimRight(s string, cutset string) string
func TrimRightFunc(s string, f func(rune) bool) string
func TrimSpace(s string) string
func TrimSuffix(s, suffix string) string
func Map(mapping func(rune) rune, s string) string
func Repeat(s string, count int) string
func Replace(s, old, new string, n int) string
type Reader
func NewReader(s string) *Reader
func (r *Reader) Len() int
func (r *Reader) Read(b []byte) (n int, err error)
func (r *Reader) ReadAt(b []byte, off int64) (n int, err error)
func (r *Reader) ReadByte() (byte, error)
func (r *Reader) ReadRune() (ch rune, size int, err error)
func (r *Reader) Reset(s string)
func (r *Reader) Seek(offset int64, whence int) (int64, error)
func (r *Reader) Size() int64
func (r *Reader) UnreadByte() error
func (r *Reader) UnreadRune() error
func (r *Reader) WriteTo(w io.Writer) (n int64, err error)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。