package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)\b(.*?])\s(__declspec.+?\)\))(.*?;)`)
var str = `#if defined (_MSC_VER) && !defined(__clang__)
double pU0[3*4*K_MAX_STACK] __declspec(align(64));
#else
double pU0[3*4*K_MAX_STACK] __attribute__ ((aligned (64)));
#endif
#if defined (_MSC_VER) && !defined(__clang__)
double CC[16] __declspec(align(64)) = {0};
#else
double CC[16] __attribute__ ((aligned (64))) = {0};
#endif
#if defined (_MSC_VER) && !defined(__clang__)
double pU[3*4*K_MAX_STACK] __declspec(align(64));
#else
double pU[3*4*K_MAX_STACK] __attribute__ ((aligned (64)));
#endif`
var substitution = "$2 $1$3"
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/