feat(template): add regex support

resolves #2823
This commit is contained in:
Jan De Dobbeleer 2022-09-25 09:25:53 +02:00 committed by Jan De Dobbeleer
parent 5b6cf08acc
commit 25fa43c1d3
2 changed files with 13 additions and 0 deletions

View file

@ -12,6 +12,8 @@ func funcMap() template.FuncMap {
"url": url,
"path": path,
"glob": glob,
"matchP": matchP,
"replaceP": replaceP,
}
for key, fun := range sprig.TxtFuncMap() {
if _, ok := funcMap[key]; !ok {

11
src/template/regex.go Normal file
View file

@ -0,0 +1,11 @@
package template
import "oh-my-posh/regex"
func matchP(pattern, text string) bool {
return regex.MatchString(pattern, text)
}
func replaceP(pattern, text, replaceText string) string {
return regex.ReplaceAllString(pattern, text, replaceText)
}