package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)\b(??px)(?<!(?<!\S)\.)(\d*)(\d)(?:\.(\d+))?px\b`)
var str = `font-size: 10px;
border: 0px;
margin-top: 4px; // dont touch
margin-bottom: 12px;
margin-right: 50%;
margin-left: -12px;
padding-left: 120px;
padding-right: 8px;
border-radius: calc(50% - 1px); // dont touch
grid-template-columns: 1fr 44px 1fr;
margin-top: 36.4px;
border-width: 10.5px;
border-width: .3px; // dont touch
border-width: .6px; // dont touch
border-width: 3.3px; // dont touch
border-width: 6.6px 4px 8000px .34px;
margin-left: -1px; // dont touch`
var substitution = "$1.$2$3rem"
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/