package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?i)(\b.{1,25})(?:\s+|$)`)
var str = `Please write a program that breaks this text into small chucks. Each chunk should have a maximum length of 25 `
var substitution = "\1\n"
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/