Trying to capitalize each letter at begin of the word. I know that there is strings.Title
, but that is too imprecise for my needs.
I am not sure why this does not work:
package main
import (
"fmt"
"regexp"
"strings"
)
func main() {
re := regexp.MustCompile(`\b([a-z])`)
fmt.Println(re.ReplaceAllString("my test string", strings.ToUpper("$1")))
}