zoukankan      html  css  js  c++  java
  • golang替换字符串区分大小写

    test := "a,b,c,d,e"
        aaa := test
        keywordSlice := strings.Split(test,",")
        for _,v := range keywordSlice{
            reg := regexp.MustCompile("(?i)"+v)
            aaa = reg.ReplaceAllString(aaa,"<b class='f-red'>"+strings.ToUpper(v)+"</b>")
            fmt.Println(aaa)
        }

    <b class='f-red'>A</b>,b,c,d,e
    <<b class='f-red'>B</b> class='f-red'>A</<b class='f-red'>B</b>>,<b class='f-red'>B</b>,c,d,e
    <<b <b class='f-red'>C</b>lass='f-red'>B</b> <b class='f-red'>C</b>lass='f-red'>A</<b <b class='f-red'>C</b>lass='f-red'>B</b>>,<b <b class='f-red'>C</b>lass='f-red'>B</b>,<b class='f-red'>C</b>,d,e
    <<b <b class='f-re<b class='f-red'>D</b>'>C</b>lass='f-re<b class='f-red'>D</b>'>B</b> <b class='f-re<b class='f-red'>D</b>'>C</b>lass='f-re<b class='f-red'>D</b>'>A</<b <b class='f-re<b class='f-red'>D</b>'>C</b>lass='f-re<b class='f-red'>D</b>'>B</b>>,<b <b class='f-re<b class='f-red'>D</b>'>C</b>lass='f-re<b class='f-red'>D</b>'>B</b>,<b class='f-re<b class='f-red'>D</b>'>C</b>,<b class='f-red'>D</b>,e
    <<b <b class='f-r<b class='f-red'>E</b><b class='f-r<b class='f-red'>E</b>d'>D</b>'>C</b>lass='f-r<b class='f-red'>E</b><b class='f-r<b class='f-red'>E</b>d'>D</b>'>B</b> <b class='f-r<b class='f-red'>E</b><b class='f-r<b class='f-red'>E</b>d'>D</b>'>C</b>lass='f-r<b class='f-red'>E</b><b class='f-r<b class='f-red'>E</b>d'>D</b>'>A</<b <b class='f-r<b class='f-red'>E</b><b class='f-r<b class='f-red'>E</b>d'>D</b>'>C</b>lass='f-r<b class='f-red'>E</b><b class='f-r<b class='f-red'>E</b>d'>D</b>'>B</b>>,<b <b class='f-r<b class='f-red'>E</b><b class='f-r<b class='f-red'>E</b>d'>D</b>'>C</b>lass='f-r<b class='f-red'>E</b><b class='f-r<b class='f-red'>E</b>d'>D</b>'>B</b>,<b class='f-r<b class='f-red'>E</b><b class='f-r<b class='f-red'>E</b>d'>D</b>'>C</b>,<b class='f-r<b class='f-red'>E</b>d'>D</b>,<b class='f-red'>E</b>

  • 相关阅读:
    标准化:释放物联网全部潜力的万能钥匙
    Linux系统中如何删除交换文件,来解决突然关闭命令行,导致文件无法打开的问题
    echarts设置图例以及网络格局的相关细节设置
    JSON.parse()与JSON.stringify()的区别,具体例子,一看就明白
    HttpServletRequest
    HttpServletResponse
    JavaWeb核心之Servlet
    Http协议和Tomcat服务器
    dom4j解析
    DTD和Schema约束
  • 原文地址:https://www.cnblogs.com/sunlong88/p/13360481.html
Copyright © 2011-2022 走看看