Did you know that Go supports Perl-style template expansion for regular expressions? Using this tool, you can capture a regular expression pattern and then expand it into a simple string template. Here's how it works.
package main import ( "fmt" "os" "regexp" ) func main() { dst := make([]byte, 0, 1024) source := `"matt"` re := regexp.MustCompile(`"(?P<name>[a-z]+)"`) tpl := "My name is ${name}." matches := re.FindStringSub...
Published on February 29, 2016 08:28