1 Star 0 Fork 0

笑看风云 / gocodes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
replace.go 614 Bytes
一键复制 编辑 原始数据 按行查看 历史
笑看风云 提交于 2023-03-07 14:39 . 提交
package stringx
import (
"gitee.com/zhongguo168a/gocodes/datax/mapx"
"regexp"
"strings"
)
// ${_id}:${内网地址}
func ReplaceForamtTypeScript(format string, obj map[string]interface{}) string {
结果 := format
变量集合正则 := regexp.MustCompile(`\$\{([一-龥A-Za-z0-9_]+)}`)
变量集合 := 变量集合正则.FindAllStringSubmatch(format, -1)
for i := 0; i < len(变量集合); i++ {
变量数组 := 变量集合[i]
替换名字 := 变量数组[0]
变量名字 := 变量数组[1]
结果 = strings.Replace(结果, 替换名字, mapx.String(obj, 变量名字), -1)
}
return 结果
}
Go
1
https://gitee.com/zhongguo168a/gocodes.git
git@gitee.com:zhongguo168a/gocodes.git
zhongguo168a
gocodes
gocodes
46752958e769

搜索帮助