You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: regexp.go
    path of file: ./repos/fyne/data/validation
    
    the code of the file until where you have to start completion: // Package validation provides validation for data inside widgets.
package validation

import (
	"errors"
	"regexp"

	"fyne.io/fyne/v2"
)

// NewRegexp creates a new validator that uses r
    
func NewRegexp(regexpstr, reason string) fyne.StringValidator {
	expression, err := regexp.Compile(regexpstr)
	if err != nil {
		fyne.LogError("Regexp did not compile", err)
		return nil
	}

	err = errors.New(reason)
	return func(text string) error {
		if expression != nil && !expression.MatchString(text) {
			return err
		}

		return nil // Nothing to validate with, same as having no validator.
	}
}