code: func NewGenerator(pattern string, inputArgs *GeneratorArgs) (generator Generator, err error) {
  	args := GeneratorArgs{}
  
  	// Copy inputArgs so the caller can't change them.
  	if inputArgs != nil {
  		args = *inputArgs
  	}
  	if err = args.initialize(); err != nil {
  		return nil, err
  	}
  
  	var regexp *syntax.Regexp
  	regexp, err = syntax.Parse(pattern, args.Flags)
  	if err != nil {
  		return
  	}
  
  	var gen *internalGenerator
  	gen, err = newGenerator(regexp, &args)
  	if err != nil {
  		return
  	}
  
  	return gen, nil
  }
docs: // NewGenerator creates a generator that returns random strings that match the regular expression in pattern.
  // If args is nil, default values are used.