package main

 import "fmt"
import s"strings" var p = fmt.Println func main() {
p("Contains: ",s.Contains("test","es"))
p("Count: ",s.Count("test","t"))
p("hasPrefix: ",s.HasPrefix("test","te"))
p("HasSuffix: ",s.HasSuffix("test","st"))
p("index: ",s.Index("test","e"))
p("Join; ",s.Join([]string{"a","b"},"-"))
p("Repeat: ",s.Repeat("a",))
p("Replace: ",s.Replace("foo","o","",-))
p("Replace: ",s.Replace("foo","o","",))
p("Split: ",s.Split("a-b-c-d-e","-"))
p("ToLower: ",s.ToLower("TEST"))
p("ToUpper: ",s.ToUpper("test"))
p() p("Len: ",len("hello"))
p("Char: ","hello"[])
}

显示如下

Contains: true
Count: 2
hasPrefix: true
HasSuffix: true
index: 1
Join; a-b
Repeat: aaaaa
Replace: f00
Replace: f0o
Split: [a b c d e]
ToLower: test
ToUpper: TEST

Len: 5
Char: 101

go语言字符串练习的更多相关文章

  1. C语言字符串操作总结大全(超详细)

    本篇文章是对C语言字符串操作进行了详细的总结分析,需要的朋友参考下 1)字符串操作  strcpy(p, p1) 复制字符串  strncpy(p, p1, n) 复制指定长度字符串  strcat( ...

  2. C语言字符串拷贝

    C语言字符串拷贝利用指针操作,要清楚知道指针的指向 代码如下: #include <stdio.h> #include <assert.h> #include <stri ...

  3. C语言字符串长度(转)

    C语言字符串长度的计算是编程时常用到的,也是求职时必考的一项. C语言本身不限制字符串的长度,因而程序必须扫描完整个字符串后才能确定字符串的长度. 在程序里,一般会用strlen()函数或sizeof ...

  4. C语言字符串操作常用库函数

    C语言字符串操作常用库函数 *********************************************************************************** 函数 ...

  5. c语言字符串操作大全

     C语言字符串操作函数 函数名: strcpy 功  能: 拷贝一个字符串到另一个 用  法: char *stpcpy(char *destin, char *source); 程序例: #incl ...

  6. 转:C语言字符串操作函数 - strcpy、strcmp、strcat、反转、回文

    转自:C语言字符串操作函数 - strcpy.strcmp.strcat.反转.回文 C++常用库函数atoi,itoa,strcpy,strcmp的实现 作者:jcsu C语言字符串操作函数 1. ...

  7. C 语言字符串连接的 3种方式

    C 语言字符串连接的 3种方式 #include<stdio.h> #include<stdlib.h> #include<string.h> char *join ...

  8. C语言字符串声明

    重新学习C语言字符串声明char *a="nihao";char a[]="nihao";什么区别?前者定义的是指针,并且指向字符串常量“nihao”,后者是字 ...

  9. C语言字符串操作函数整理

    整理C语言字符串相关的函数,以程序方式验证,以注释方式做说明. #include<stdio.h> #include<string.h> #include<stdlib. ...

  10. 13-C语言字符串函数库

    目录: 一.C语言字符串函数库 二.用命令行输入参数 回到顶部 一.C语言字符串函数库 1 #include <string.h> 2 字符串复制 strcpy(参数1,参数2); 参数1 ...

随机推荐

  1. spring boot 代理(not eligible for auto-proxying)

    spring 事务机制网上的案例很多,关于事务 不能回滚也有很多的类型,不同的问题有不同的处理方案,本篇博客主要介绍两种事务不能回滚的问题解决方案: 问题一:    在同一个对象中有两个方法,分别未方 ...

  2. python对ftp进行操作

    背景:需要对ftp进行操作,涉及上传和下载操作   from ftplib import FTP ftp = FTP(host=“ftp的hostname",user=‘登录用户名', pa ...

  3. 【C++】预处理过程与语句总结

    转载请保留: http://www.cnscn.org(CNS电脑与英语学习网) Author: cnscn http://www.cnscn.org 1)预处理 根据已放置在文件中的预处理指令来修改 ...

  4. 中国剩余定理模板 51nod 1079

    题目链接:传送门 推荐博客:https://www.cnblogs.com/freinds/p/6388992.html (证明很好,代码有误). 1079 中国剩余定理  基准时间限制:1 秒 空间 ...

  5. 枚举+最短路 poj1062

    这里有个非常坑的地方,还有比酋长地位还更高的人,我也是看了论坛才知道... 在这里我把编号1看成终点,优惠价格看成相应的替代品编号到可替代品编号的权值,比如说有了2再加8000就到了1,那么2到1的弧 ...

  6. gridview空间使用

    1.HTML代码 <asp:GridView ID="gv_Info" runat="server" AutoGenerateColumns=" ...

  7. SQLite4Unity3d

    What's this? When I started with Unity3d development I needed to use SQLite in my project and it was ...

  8. javascript简单的滑动效果

    利用setInterval实现简单的滑动效果 <!DOCTYPE html> <html lang="en"> <head> <meta ...

  9. Apache+PHP+MySQL环境搭建

    准备安装包:Apache: apache_2.2.11-win32.msi (http://pan.baidu.com/s/1nvdiNcH)PHP: php-5.2.5-Win32.zip (htt ...

  10. vue初学:基础概念

    一.vue使用步骤: 1.引包vue.js 2.html中写要操作的DOM节点 3.创建vue对象:new Vue({options}); 4.配置options:el:(要操作的对象,用选择器,同j ...