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. 浅了解:react为何需要设定唯一key值(antd-table)

    一.React规范 1.1 react key的作用 当渲染重复数据的时候,React.diff会根据生成的key进行虚拟DOM渲染, 所以我们需要在遍历的地方都要加上key,例如map.for等等 ...

  2. python 自定义异常

    python2 #coding=utf- class CustomError(Exception):     def __init__(self,ErrorInfo):         self.er ...

  3. sqlserver数据库中sql的使用

    目录: 1. 分组排序更新 2. 将查询结果插入到新的表中 3. 创建/更新存储过程 4. 创建/更新视图 5. 插入数据 6. 增加表格的列 7. 创建表格 8. 创建索引 9. 递归查询 1. 分 ...

  4. python检测服务器端口

    import socket sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sk.settimeout(10) try: sk.conne ...

  5. SecureCRT自动断开

    解决方法 可以通过两个入口进行设置: 1.右击Session中的连接,选择Properties->Terminal->Anti-idle->勾选Send protocol NO-OP ...

  6. Kafka学习之二 Kafka安装和使用

    部署环境Linux(Centos 6.5),JDK 1.8.0,zookeeper-3.4.12,kafka_2.11-2.0.0. 1. 单机环境     官方建议使用JDK 1.8版本,因此本文使 ...

  7. Flask离线文档 --技术文档

    1.预览 2.文档下载 链接:Flask离线文档下载(v1.0.10)提取码:0x0x 

  8. stimulus(6300✨)

    https://github.com/stimulusjs/stimulus 一个现代JS框架,不会完全占据你的前端,事实上它不涉及渲染HTML. 相反,它被设计用于增加你的HTML和刚刚够好的beh ...

  9. ml交叉验证

    https://blog.csdn.net/guanyuqiu/article/details/86006474 https://blog.csdn.net/weixin_42660173/artic ...

  10. [LeetCode]题1:two sum

      Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0 ...