can newreplacer.replace case insensitive string replacement?
r := strings.newreplacer("html", "xml") fmt.println(r.replace("this <b>html</b>!")) if not, what's best way case insensitive string replace in go?
you can use regular expressions that:
re := regexp.mustcompile(`(?i)html`) fmt.println(re.replaceallstring("html html html", "xml")) playground: http://play.golang.org/p/h0gk6pbp2c.
it's worth noting case thing can different depending on language , locale. example, capital form of german letter "ß" "ss". while doesn't influence english texts, bear in mind when working multi-lingual texts , programs need work them.
Comments
Post a Comment