package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`\b(\d{3})(\d{3})(\d{4})\b`)
var str = `reformat several 10-digit numeral strings to telephone number format
Hello. I'm looking for regex to use with LibreOffice Calc find-and-replace function to format 10-digit numbers into telephone number format. Example: reformat
4018286606 to be (401) 828-6606
I tried this:
FIND (\[0-9\]{10})
REPLACE WITH \^(\\(\[0-9\]{3}\\)\\s\[0-9\]{3}-\[0-9\]{4})
Not working.
Using LibreOffice [25.8.4.2](http://25.8.4.2)
Thank you.
`
var substitution = "($1) $2-$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/