示例#1
0
// ReadRegexp prints the prompt waiting to get a string that matches with a regular expression.
func (q *Question) ReadRegexp(options, pattern string) (string, error) {
	valida := validate.NewRegexp(q.mod, options, pattern)
	if q.defValue != nil {
		valida.SetDefault(q.defValue)
		q.defString = defaultToPrint(q.defValue)
	}

	value, err := q.read(q.newLine(), valida)
	q.clean()
	return value.(string), err
}
示例#2
0
文件: quest.go 项目: postfix/term
// NewRegexp sets a regular expression "re" with a name to be identified.
func (q *Question) NewRegexp(name, re string) *Question {
	q.val = validate.NewRegexp(q.mod, name, re)
	return q
}