package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`((\s*(const|let|var)\s*)(\w+)(\s*=\s*)(require\s*\(")(\w+)("\s*\)\s*;))`)
var str = `const path = require ("path") ;
let path = require("path");
var path = require("path");`
var substitution = "$4,$7"
fmt.Println(re.ReplaceAllString(str, substitution))
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/