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>

  • 相关阅读:
    第十周学习进度条
    第九周学习进度条
    Runner站立会议08
    Runner站立会议07
    构建之法阅读笔记02
    Runner站立会议04
    学习进度条
    Runner站立会议01
    进度条
    返回一个一维整数数组中最大子数组的和
  • 原文地址:https://www.cnblogs.com/sunlong88/p/13360481.html
Copyright © 2011-2022 走看看