package main

import (
"fmt"
s "strings"
) var p = fmt.Println func main() {
//strings标准库包含的函数
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", 5))
p("Replace", s.Replace("foo", "o", "0", -1))
p("Replace", s.Replace("foo", "o", "0", 1))
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"[1])
}

Go Example--strings的更多相关文章

  1. Hacker Rank: Two Strings - thinking in C# 15+ ways

    March 18, 2016 Problem statement: https://www.hackerrank.com/challenges/two-strings/submissions/code ...

  2. StackOverFlow排错翻译 - Python字符串替换: How do I replace everything between two strings without replacing the strings?

    StackOverFlow排错翻译 - Python字符串替换: How do I replace everything between two strings without replacing t ...

  3. Multiply Strings

    Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...

  4. [LeetCode] Add Strings 字符串相加

    Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. ...

  5. [LeetCode] Encode and Decode Strings 加码解码字符串

    Design an algorithm to encode a list of strings to a string. The encoded string is then sent over th ...

  6. [LeetCode] Group Shifted Strings 群组偏移字符串

    Given a string, we can "shift" each of its letter to its successive letter, for example: & ...

  7. [LeetCode] Isomorphic Strings 同构字符串

    Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the chara ...

  8. [LeetCode] Multiply Strings 字符串相乘

    Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...

  9. 使用strings查看二进制文件中的字符串

    使用strings查看二进制文件中的字符串 今天介绍的这个小工具叫做strings,它实现功能很简单,就是找出文件内容中的可打印字符串.所谓可打印字符串的涵义是,它的组成部分都是可打印字符,并且以nu ...

  10. LeetCode 205 Isomorphic Strings

    Problem: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if ...

随机推荐

  1. 【SMTP】常见错误码

    '* 邮件服务返回代码含义 '* 500 格式错误,命令不可识别(此错误也包括命令行过长) '* 501 参数格式错误 '* 502 命令不可实现 '* 503 错误的命令序列 '* 504 命令参数 ...

  2. 更改ssh,ftp默认端口

    1.  更改ssh端口 放置升级openssh之后做此步骤 配置文件/etc/ssh/sshd_config 注释掉Subsystem      sftp    /usr/libexec/openss ...

  3. caffe生成deploy.prototxt文件

    参考: http://blog.csdn.net/cham_3/article/details/52682479 以caffe工程自带的mnist数据集,lenet网络为例: 将lenet_train ...

  4. yii中的restful方式输出并调用接口和判断用户是否登录状态

    //创建一个控制器接口 返回的是restful方式 <?php namespace frontend\controllers; use frontend\models\Fenlei; use f ...

  5. python学习(八)

  6. Struts2中 Action class not found 问题

    刚学Struts2时碰到了以下两个问题,都是没有正确配置struts.xml导致的,自己记录一下: 1.浏览器报404:The origin server did not find a current ...

  7. 『PyTorch』第五弹_深入理解Tensor对象_下:从内存看Tensor

    Tensor存储结构如下, 如图所示,实际上很可能多个信息区对应于同一个存储区,也就是上一节我们说到的,初始化或者普通索引时经常会有这种情况. 一.几种共享内存的情况 view a = t.arang ...

  8. 『OpenCV3』滤波器实现及使用滤波器降噪

    一.滤波器实现 我们实现这样一个基于拉普拉斯算子的滤波器核心,并使用它进行滤波,这可以做到锐化图像的效果, 0 -1 0 -1 5 -1 0 -1 0 首先我们完全手动的进行滤波,依赖指针操作, vo ...

  9. vue中动态加载组件+开发者模式+JS参数值传递和引用传递

    今天写vue里面通过接口反参动态加载组件时候 跟着同学...学习到了 一.先说说vue 内置组件 component 的用法 component组件可以来专门用来进行组件的切换,使用is来绑定你的组件 ...

  10. python几种常见的模块安装方法

    1. 在线安装 1.1 在命令提示符中运行 pip install package_name 指令  注:具体前置步骤和教程:http://www.cnblogs.com/jfl-xx/p/72895 ...