zoukankan      html  css  js  c++  java
  • 2.1 字符串查询

    package main
    
    import (
    	"fmt"
    	"strings"
    )
    
    const refString = "Mary had a little lamb"
    
    func main() {
    
    	lookFor := "lamb"
    	contain := strings.Contains(refString, lookFor)
    	fmt.Printf("The "%s" contains "%s": %t 
    ", refString, lookFor, contain)
    
    	lookFor = "wolf"
    	contain = strings.Contains(refString, lookFor)
    	fmt.Printf("The "%s" contains "%s": %t 
    ", refString, lookFor, contain)
    
    	startsWith := "Mary"
    	starts := strings.HasPrefix(refString, startsWith)
    	fmt.Printf("The "%s" starts with "%s": %t 
    ", refString, startsWith, starts)
    
    	endWith := "lamb"
    	ends := strings.HasSuffix(refString, endWith)
    	fmt.Printf("The "%s" ends with "%s": %t 
    ", refString, endWith, ends)
    
    }
    
    /*
    The "Mary had a little lamb" contains "lamb": true
    The "Mary had a little lamb" contains "wolf": false
    The "Mary had a little lamb" starts with "Mary": true
    The "Mary had a little lamb" ends with "lamb": true
    */
    
    
  • 相关阅读:
    python爬虫
    绕过CDN查找网站真实IP方法收集
    拖库
    伪静态注入的总结
    国外安全网站信息收集
    python字典去重脚本
    AOP 的利器:ASM 3.0 介绍
    JDK工具
    JVM性能调优监控工具
    DMZ
  • 原文地址:https://www.cnblogs.com/zrdpy/p/8620193.html
Copyright © 2011-2022 走看看