'Golang how to replace string in regex group? [duplicate]

I want to replace strings:

"hello [Jim], I'm [Sam]" to "hello [MR Jim], I'm [MR Sam]"

"[Greetings] hello [Jim], I'm [Sam]" to "[Greetings] hello [MR Jim], I'm [MR Sam]"

How can I do this via golang regex?

re := regexp.MustCompile(`hello [(\w+)], I'm [(\w+)]`)

Thank you very much!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source