Replaces all properties with the same name as the supplied properties.

@param replacement property to replace with
@return a new copy of the template
512614
public Data replace(Iterable<Property> replacement) {
        if (Iterables.isEmpty(replacement)) {
            return this;
        }
        Map<String, Property> map = getDataAsMap(replacement);

        List<Property> props = this.stream().
                map(f -> map.getOrDefault(f.getName(), f)).
                collect(Collectors.toList());

        return new Data(props);
    }
731995
public static SuggestedFix renameVariable(
      VariableTree tree, final String replacement, VisitorState state) {
    String name = tree.getName().toString();
    int typeEndPos = state.getEndPosition(tree.getType());
    // handle implicit lambda parameter types
    int searchOffset = typeEndPos == -1 ? 0 : (typeEndPos - ((JCTree) tree).getStartPosition());
    int pos =
        ((JCTree) tree).getStartPosition()
            + state.getSourceForNode(tree).indexOf(name, searchOffset);
    final SuggestedFix.Builder fix =
        SuggestedFix.builder().replace(pos, pos + name.length(), replacement);
    final Symbol.VarSymbol sym = getSymbol(tree);
    ((JCTree) state.getPath().getCompilationUnit())
        .accept(
            new TreeScanner() {
              @Override
              public void visitIdent(JCTree.JCIdent tree) {
                if (sym.equals(getSymbol(tree))) {
                  fix.replace(tree, replacement);
                }
              }

              @Override
              public void visitSelect(JCTree.JCFieldAccess tree) {
                if (sym.equals(getSymbol(tree))) {
                  fix.replace(
                      state.getEndPosition(tree.getExpression()),
                      state.getEndPosition(tree),
                      "." + replacement);
                }
                super.visitSelect(tree);
              }
            });
    return fix.build();
  }
1316963
public void replace(BaseCell oldOne, BaseCell newOne) {
        VirtualLayoutManager layoutManager = getLayoutManager();
        if (oldOne != null && newOne != null && mGroupBasicAdapter != null && layoutManager != null) {
            int replacePosition = mGroupBasicAdapter.getPositionByItem(oldOne);
            if (replacePosition >= 0) {
                int cardIdx = mGroupBasicAdapter.findCardIdxFor(replacePosition);
                Card card = mGroupBasicAdapter.getCardRange(cardIdx).second;
                card.replaceCell(oldOne, newOne);
                mGroupBasicAdapter.replaceComponent(Arrays.asList(oldOne), Arrays.asList(newOne));
            }
        }
    }
798263
public boolean replace(Object e1, Object e2) {
        return replace(fromObject(e1),fromObject(e2));
    }
139150
public ParallelTaskBuilder setReplaceVarMapToSingleTargetSingleVar(
            String variable, List<String> replaceList, String uniformTargetHost) {

        if (Strings.isNullOrEmpty(uniformTargetHost)) {
            logger.error("uniform target host is empty or null. skil setting.");
            return this;
        }
        this.replacementVarMapNodeSpecific.clear();
        this.targetHosts.clear();
        int i = 0;
        for (String replace : replaceList) {
            if (replace == null){
                logger.error("null replacement.. skip");
                continue;
            }
            String hostName = PcConstants.API_PREFIX + i;

            replacementVarMapNodeSpecific.put(
                    hostName,
                    new StrStrMap().addPair(variable, replace).addPair(
                            PcConstants.UNIFORM_TARGET_HOST_VAR,
                            uniformTargetHost));
            targetHosts.add(hostName);
            ++i;
        }
        this.requestReplacementType = RequestReplacementType.TARGET_HOST_SPECIFIC_VAR_REPLACEMENT;
        logger.info(
                "Set requestReplacementType as {} for single target. Will disable the set target hosts."
                        + "Also Simulated "
                        + "Now Already set targetHost list with size {}. \nPLEASE NOT TO SET TARGET HOSTS AGAIN WITH THIS API.",
                requestReplacementType.toString(), targetHosts.size());

        return this;
    }
936812
public static String replaceAll(CharSequence content, String regex, String replacementTemplate) {
		final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
		return replaceAll(content, pattern, replacementTemplate);
	}
807574
private String stringReplace(String text, String target, String replacement) {
		return Pattern.compile(target.toString(), Pattern.LITERAL).matcher(
				text).replaceAll(replacement);
	}
247300
public MultiChangeBuilder<PS, SEG, S> replace(int start, int end, StyledDocument<PS, SEG, S> replacement) {
        return relativeReplace(start, end, ReadOnlyStyledDocument.from(replacement));
    }
775307
protected Properties replacePlaceHolders(Properties props){
		if (replacePlaceHolders){
			Properties result = new Properties();
			for (Object keyObj: props.keySet()){
				String key = (String) keyObj;
				String value = props.getProperty(key);
				key = PlaceHolderReplacer.replaceWithProperties(key);
				value = PlaceHolderReplacer.replaceWithProperties(value);
				result.put(key, value);
			}
			return result;
		}else{
			return props;
		}
	}
120296
private static String replaceProperties(final String value) {
        final StringBuilder builder = new StringBuilder();
        final int len = value.length();
        int state = 0;
        int start = -1;
        int nameStart = -1;
        for (int i = 0; i < len; i = value.offsetByCodePoints(i, 1)) {
            final char ch = value.charAt(i);
            switch (state) {
                case INITIAL: {
                    switch (ch) {
                        case '$': {
                            state = GOT_DOLLAR;
                            continue;
                        }
                        default: {
                            builder.append(ch);
                            continue;
                        }
                    }
                    // not reachable
                }
                case GOT_DOLLAR: {
                    switch (ch) {
                        case '$': {
                            builder.append(ch);
                            state = INITIAL;
                            continue;
                        }
                        case '{': {
                            start = i + 1;
                            nameStart = start;
                            state = GOT_OPEN_BRACE;
                            continue;
                        }
                        default: {
                            // invalid; emit and resume
                            builder.append('$').append(ch);
                            state = INITIAL;
                            continue;
                        }
                    }
                    // not reachable
                }
                case GOT_OPEN_BRACE: {
                    switch (ch) {
                        case ':':
                        case '}':
                        case ',': {
                            final String name = value.substring(nameStart, i).trim();
                            if ("/".equals(name)) {
                                builder.append('/');
                                state = ch == '}' ? INITIAL : RESOLVED;
                                continue;
                            } else if (":".equals(name)) {
                                builder.append('/');
                                state = ch == '}' ? INITIAL : RESOLVED;
                                continue;
                            }
                            final String val = null;//System.getProperty(name);
                            if (val != null) {
                                builder.append(val);
                                state = ch == '}' ? INITIAL : RESOLVED;
                                continue;
                            } else if (ch == ',') {
                                nameStart = i + 1;
                                continue;
                            } else if (ch == ':') {
                                start = i + 1;
                                state = DEFAULT;
                                continue;
                            } else {
                                builder.append(value.substring(start - 2, i + 1));
                                state = INITIAL;
                                continue;
                            }
                        }
                        default: {
                            continue;
                        }
                    }
                    // not reachable
                }
                case RESOLVED: {
                    if (ch == '}') {
                        state = INITIAL;
                    }
                    continue;
                }
                case DEFAULT: {
                    if (ch == '}') {
                        state = INITIAL;
                        builder.append(value.substring(start, i));
                    }
                    continue;
                }
                default: throw new IllegalStateException();
            }
        }
        switch (state) {
            case GOT_DOLLAR: {
                builder.append('$');
                break;
            }
            case DEFAULT:
            case GOT_OPEN_BRACE: {
                builder.append(value.substring(start - 2));
                break;
            }
        }
        return builder.toString();
    }
245903
public static final <T> Function<Object,T> replaceWith(final T object) {
        return new ReplaceWith<T>(object);
    }
593017
@Override
    public ReplaceDeploymentPlanBuilder andReplace(String toReplace) {
        String newContentKey = getAddedContentKey();
        return replace(newContentKey, toReplace);
    }
322994
private void replaceProperties(Set<CmsResource> matchedResources) {

        for (CmsResource resource : matchedResources) {
            try {
                CmsProperty prop = getCms().readPropertyObject(resource, m_settings.getProperty().getName(), false);
                Matcher matcher = Pattern.compile(m_settings.getSearchpattern()).matcher(prop.getValue());
                if (m_settings.getReplacepattern().isEmpty()) {
                    prop.setValue("", "");
                } else {
                    prop.setValue(matcher.replaceAll(m_settings.getReplacepattern()), CmsProperty.TYPE_INDIVIDUAL);
                }
                getCms().lockResource(resource);
                getCms().writePropertyObjects(resource, Collections.singletonList(prop));
                getCms().unlockResource(resource);
            } catch (CmsException e) {
                LOG.error("Ubable to change property", e);
            }
        }
    }
1249654
public String replaceNonMembers(String input, char replacement) {
    if (!contains(replacement)) {
      throw new IllegalArgumentException(replacement + " is not a member of " + pattern);
    }
    return containsAll(input) ? input : replaceNonMembersImpl(input, replacement);
  }
1230701
function replace(pattern, replacement, val){
  utils.assertString(pattern, 'pattern');
  utils.assertString(replacement, 'replacement');
  utils.assertString(val, 'val');
  pattern = new RegExp(pattern.string, 'g');
  var res = val.string.replace(pattern, replacement.string);
  return val instanceof nodes.Ident
    ? new nodes.Ident(res)
    : new nodes.String(res);
}
45952
public static StringBuilder replaceResources(StringBuilder sb, ResourceBundle reg, Map<String, Object> map, PropertyOwner propertyOwner)
    {
        return Utility.replaceResources(sb, reg, map, propertyOwner, false);
    }
1209553
String replace(String source) {
        if (source == null)
            return null;
        Matcher m = PATTERN.matcher(source);
        StringBuffer sb = new StringBuffer();
        while (m.find()) {
            String var = m.group(1);
            String value = values.getProperty(var);
            String replacement = (value != null) ? replace(value) : "";
            m.appendReplacement(sb, Matcher.quoteReplacement(replacement));
        }
        m.appendTail(sb);
        return sb.toString();
    }