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. 牛客-数据库SQL实战

    查找最晚入职员工的所有信息 CREATE TABLE `employees` ( `emp_no` ) NOT NULL, `birth_date` date NOT NULL, `first_nam ...

  2. gym 101081 E. Polish Fortress 几何

    E. Polish Fortress time limit per test 2.0 s memory limit per test 256 MB input standard input outpu ...

  3. DP入门水题集

    HDU 1087 Input contains multiple test cases. Each test case is described in a line as follow:N value ...

  4. 更改redhat7 yum源为centos

    1. 替换原系统中yum包, 检查初始的yum包有哪些 rpm -qa |grep yum 2. 删除原始的yum包. rpm -qa|grep yum|xargs rpm -e --nodeps 3 ...

  5. [Vue]createElement参数

    一.createElement 函数模板 // @returns {VNode} createElement( // {String | Object | Function} // 一个 HTML 标 ...

  6. spark中的combineByKey函数的用法

    一.函数的源码 /** * Simplified version of combineByKeyWithClassTag that hash-partitions the resulting RDD ...

  7. English trip EM2-LP-4B At School Teacher:Russell

    课上内容(Lesson) Where is Loki a student?  Loki is in Meten, BaobaoStreet, Chengdu. What is he studying? ...

  8. Django+七牛上传+查看+下载文件相关函数,新整理未完全测试

    M class File(models.Model): # 文档模型 name = models.CharField(max_length=255) staff = models.ForeignKey ...

  9. Matlab:五点差分方法求解椭圆方程非导数边值问题

    差分格式脚本文件: tic; clear clc M=32;%x的步数 N=16;%y的步数 h1=1/M;%x的步长 h2=1/N;%y的步长 x=0:h1:1; y=0:h2:1; u=zeros ...

  10. 第K个幸运数字(4、7)

    题目:4和7是两个幸运数字,我们定义,十进制表示中,每一位只有4和7两个数的正整数都是幸运数字,前几个幸运数字为:4,7,44,47,74,77,444,447······输出第K个数字. 思路是:将 ...