// ReplaceAll replaces all occurrences of the regex with the replacement.
555012
func ReplaceAll(source Expr, regex Expr, replacement Expr) Expr {
	regexString := ""
	_regex, ok := regex.(*constant)
	if ok {
		regexString = fmt.Sprint(_regex.Eval(nil))
	} else {
		fmt.Println("Regex is not a constant!")
		regexString = ""
	}
	e := &replaceAll{Source: source, Regex: regexString, Replacement: replacement}
	e.initReplacer()
	return e
}
956701
func (s *SecondaryCache) Replace(secondary string, value interface{}) bool {
	item := s.Get(secondary)
	if item == nil {
		return false
	}
	s.Set(secondary, value, item.TTL())
	return true
}
565516
func (t Term) Replace(arg interface{}, optArgs ...ReplaceOpts) Term {
	opts := map[string]interface{}{}
	if len(optArgs) >= 1 {
		opts = optArgs[0].toMap()
	}
	return constructMethodTerm(t, "Replace", p.Term_REPLACE, []interface{}{funcWrap(arg)}, opts)
}
1101651
func replaceFirst(s string, args ...string) string {
	switch len(args) {
	case 0:
		return s
	case 1:
		return strings.Replace(s, args[0], "", 1)
	default:
		return strings.Replace(s, args[0], args[1], 1)
	}
}
214086
func (s *Selection) ReplaceWith(selector string) *Selection {
	return s.ReplaceWithMatcher(compileMatcher(selector))
}
908892
func (p *Partition) replaceFileSet(fs *FileSet) {
	p.fileSet.Release()
	p.fileSet = fs
}
954421
func (h Handler) Replace(cmd common.SetRequest) error {
	_, err := h.doRequest(cmd, common.RequestReplace)
	return err
}
966854
func (ns *Namespace) Replace(s, old, new interface{}) (string, error) {
	ss, err := cast.ToStringE(s)
	if err != nil {
		return "", err
	}

	so, err := cast.ToStringE(old)
	if err != nil {
		return "", err
	}

	sn, err := cast.ToStringE(new)
	if err != nil {
		return "", err
	}

	return _strings.Replace(ss, so, sn, -1), nil
}
1338790
func (c *Cache) Replace(key string, value interface{}) bool {
	item := c.bucket(key).get(key)
	if item == nil {
		return false
	}
	c.Set(key, value, item.TTL())
	return true
}
605317
func (j *Job) Replaces() []string {
	replaces := make([]string, 0)
	replaces = append(replaces, j.requirements()[fleetReplaces]...)
	return replaces
}
693834
func (f *ReFuncs) ReplaceLiteral(re, replacement, input interface{}) (string, error) {
	return regexp.ReplaceLiteral(conv.ToString(re),
		conv.ToString(replacement),
		conv.ToString(input))
}
112248
func (s *RepositoriesService) ReplaceAllTopics(ctx context.Context, owner, repo string, topics []string) ([]string, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/topics", owner, repo)
	t := &repositoryTopics{
		Names: topics,
	}
	if t.Names == nil {
		t.Names = []string{}
	}
	req, err := s.client.NewRequest("PUT", u, t)
	if err != nil {
		return nil, nil, err
	}

	// TODO: remove custom Accept header when this API fully launches.
	req.Header.Set("Accept", mediaTypeTopicsPreview)

	t = new(repositoryTopics)
	resp, err := s.client.Do(ctx, req, t)
	if err != nil {
		return nil, resp, err
	}

	return t.Names, resp, nil
}
198905
func (s *Selection) ReplaceWithMatcher(m Matcher) *Selection {
	return s.ReplaceWithNodes(m.MatchAll(s.document.rootNode)...)
}
1241995
func (h Handler) Replace(cmd common.SetRequest) error {
	return h.handleSetCommon(cmd, common.RequestReplace)
}
67134
func (c *RawBinaryClient) Replace(item *Item) MutateResponse {
	if item == nil {
		return NewMutateErrorResponse("", errors.New("item is nil"))
	}

	c.mutex.Lock()
	defer c.mutex.Unlock()

	if resp := c.sendMutateRequest(opReplace, item, true); resp != nil {
		return resp
	}

	return c.receiveMutateResponse(opReplace, item.Key)
}
986038
func ReplaceLiteral(expression, replacement, input string) (string, error) {
	re, err := stdre.Compile(expression)
	if err != nil {
		return "", err
	}
	return re.ReplaceAllLiteralString(input, replacement), nil
}
1145443
func Substitute(template string, mapping Mapping) (string, error) {
	return SubstituteWith(template, mapping, defaultPattern, DefaultSubstituteFuncs...)
}