------------------------------------------------------------

strings 包与 bytes 包中的函数用法基本一样,不再赘述。

只对 Replacer 进行说明。

------------------------------------------------------------

// 转换

func ToUpper(s string) string
func ToLower(s string) string
func ToTitle(s string) string func ToUpperSpecial(_case unicode.SpecialCase, s string) string
func ToLowerSpecial(_case unicode.SpecialCase, s string) string
func ToTitleSpecial(_case unicode.SpecialCase, s string) string func Title(s string) string ------------------------------ // 比较 func Compare(a, b string) int func EqualFold(s, t string) bool ------------------------------ // 清理 func Trim(s string, cutset string) string
func TrimLeft(s string, cutset string) string
func TrimRight(s string, cutset string) string func TrimFunc(s string, f func(rune) bool) string
func TrimLeftFunc(s string, f func(rune) bool) string
func TrimRightFunc(s string, f func(rune) bool) string func TrimSpace(s string) string func TrimPrefix(s, prefix string) string
func TrimSuffix(s, suffix string) string ------------------------------ // 拆合 func Split(s, sep string) []string
func SplitN(s, sep string, n int) []string func SplitAfter(s, sep string) []string
func SplitAfterN(s, sep string, n int) []string func Fields(s string) []string
func FieldsFunc(s string, f func(rune) bool) []string func Join(a []string, sep string) string func Repeat(s string, count int) string ------------------------------ // 子串 func HasPrefix(s, prefix string) bool
func HasSuffix(s, suffix string) bool func Contains(s, substr string) bool
func ContainsRune(s string, r rune) bool
func ContainsAny(s, chars string) bool func Index(s, sep string) int
func IndexByte(s string, c byte) int
func IndexRune(s string, r rune) int
func IndexAny(s, chars string) int
func IndexFunc(s string, f func(rune) bool) int func LastIndex(s, sep string) int
func LastIndexByte(s string, c byte) int
func LastIndexAny(s, chars string) int
func LastIndexFunc(s string, f func(rune) bool) int func Count(s, sep string) int ------------------------------ // 替换 func Replace(s, old, new string, n int) string func Map(mapping func(rune) rune, s string) string ------------------------------------------------------------ type Reader struct { ... } func NewReader(s string) *Reader 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) WriteTo(w io.Writer) (n int64, err error)
func (r *Reader) Seek(offset int64, whence int) (int64, error) func (r *Reader) ReadByte() (byte, error)
func (r *Reader) UnreadByte() error func (r *Reader) ReadRune() (ch rune, size int, err error)
func (r *Reader) UnreadRune() error func (r *Reader) Len() int
func (r *Reader) Size() int64
func (r *Reader) Reset(s string) ------------------------------------------------------------ type Replacer struct { ... } // 创建一个替换规则,参数为“查找内容”和“替换内容”的交替形式。
// 替换操作会依次将第 1 个字符串替换为第 2 个字符串,将第 3 个字符串
// 替换为第 4 个字符串,以此类推。
// 替换规则可以同时被多个例程使用。
func NewReplacer(oldnew ...string) *Replacer // 使用替换规则对 s 进行替换并返回结果。
func (r *Replacer) Replace(s string) string // 使用替换规则对 s 进行替换并将结果写入 w。
// 返回写入的字节数和遇到的错误。
func (r *Replacer) WriteString(w io.Writer, s string) (n int, err error) ------------------------------------------------------------

Golang学习 - strings 包的更多相关文章

  1. 19-03【golang】strings包

    golang的strings包提供了字符串操作的一系列函数.下面做个简单介绍 函数 用法 备注 Compare(a,b sring) 比较两个字符串   Contains(s, substr stri ...

  2. Golang学习 - unsafe 包

    ------------------------------------------------------------ 指针类型: *类型:普通指针,用于传递对象地址,不能进行指针运算. unsaf ...

  3. golang基础学习-strings包常用函数学习

    package main import ( "fmt" "strings" ) //StrFunc 字符串说明 func main() { var testSt ...

  4. Golang学习 - sort 包

    ------------------------------------------------------------ // 满足 Interface 接口的类型可以被本包的函数进行排序. type ...

  5. Golang学习 - io 包

    ------------------------------------------------------------ 先说一下接口,Go 语言中的接口很简单,在 Go 语言的 io 包中有这样一个 ...

  6. Golang学习 - reflect 包

    ------------------------------------------------------------ 在 reflect 包中,主要通过两个函数 TypeOf() 和 ValueO ...

  7. Golang学习 - bufio 包

    ------------------------------------------------------------ // bufio 包实现了带缓存的 I/O 操作 -------------- ...

  8. Golang之strings包

    只列举了部分函数方法的使用: 太多了....... package main import ( "fmt" "strings" ) func main() { ...

  9. Golang学习 - errors 包

    ------------------------------------------------------------ Go 语言使用 error 类型来返回函数执行过程中遇到的错误,如果返回的 e ...

随机推荐

  1. POJ 1410 Intersection(判断线段交和点在矩形内)

    Intersection Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9996   Accepted: 2632 Desc ...

  2. Could not find a transformer to transform "SimpleDataType{type=org.mule.transport.NullPayload

    mule esb报错 com.isoftstone.esb.transformer.Json2RequestBusinessObject.transformMessage(Json2RequestBu ...

  3. maven缺少依赖包,强制更新命令

    mvn clean install -e -U -e详细异常,-U强制更新

  4. HDU 2544 最短路 http://acm.hdu.edu.cn/showproblem.php?pid=2544

    //代码: //方法1:Dijkstra's Algorithm #include<stdio.h> #include<math.h> #include<string.h ...

  5. CGI 是什么

    CGI是公共网关接口,是Java Servlet 的前身,Java Servlet  是运行在服务器端的小程序.

  6. IAP内购

    IAPHelper.h // // IAPHelper.h // airplay // // Created by apple on 13-10-23. // Copyright (c) 2013年 ...

  7. HTML定位(滚动条、元素,视口)定位

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. 定制个性化的FlashPaper生成的文件

    1:找到已安装FlashPaper目录下的子目录Interface下的文件DefaultViewer2.swf,在此swf文件的基础上实现自己的修改. 2:利用swf反编译工具,这里推荐 硕思闪客精灵 ...

  9. IE6中奇数宽高的BUG

    一个外部的相对定位div,内部一个绝对定位的div(right:0), 如图: 可是在IE6下查看,却变成了right:1px的效果了: IE6还有奇数宽高的bug,解决方案就是将外部相对定位的div ...

  10. li中包含span,在IE6、IE7下会有3pxbug

    如果给每个li里面加个span标签的话,在IE6,IE7下看,li与li之间的距离就会多了3px. 解决方法:在li中加vertical-align:middle; <div class=&qu ...