Replaces patterns ${XXX} by another property value, if XXX is a property key with a value.<p>
170174
protected synchronized void replaceQuerySearchPatterns() {

        String currentKey = null;
        String currentValue = null;
        int startIndex = 0;
        int endIndex = 0;
        int lastIndex = 0;

        Iterator<String> allKeys = m_queries.keySet().iterator();
        while (allKeys.hasNext()) {
            currentKey = allKeys.next();
            currentValue = m_queries.get(currentKey);
            startIndex = 0;
            endIndex = 0;
            lastIndex = 0;

            while ((startIndex = currentValue.indexOf("${", lastIndex)) != -1) {
                endIndex = currentValue.indexOf('}', startIndex);
                if ((endIndex != -1) && !currentValue.startsWith(QUERY_PROJECT_SEARCH_PATTERN, startIndex - 1)) {

                    String replaceKey = currentValue.substring(startIndex + 2, endIndex);
                    String searchPattern = currentValue.substring(startIndex, endIndex + 1);
                    String replacePattern = this.readQuery(replaceKey);

                    if (replacePattern != null) {
                        currentValue = CmsStringUtil.substitute(currentValue, searchPattern, replacePattern);
                    }
                }

                lastIndex = endIndex + 2;
            }
            m_queries.put(currentKey, currentValue);
        }
    }
179327
function(props, regex) {
            if(!(regex instanceof RegExp)) {
                return props;
            }
            var key,
                filtered = {};

            for(key in props) {
                if(props.hasOwnProperty(key) && regex.test(key)) {
                    filtered[key] = props[key];
                }
            }
            return filtered;
        }
598421
@Override
    public final void applyPattern(String pattern)
    {

        if (hasRegistry())
        {
            super.applyPattern(pattern);
            toPattern = super.toPattern();
            return;
        }

        ArrayList<Format> foundFormats = new ArrayList<Format>();
        ArrayList<String> foundDescriptions = new ArrayList<String>();
        StringBuilder stripCustom = new StringBuilder(pattern.length());

        ParsePosition pos = new ParsePosition(0);
        char[] c = pattern.toCharArray();
        int fmtCount = 0;

        while (pos.getIndex() < pattern.length())
        {

            char charType = c[pos.getIndex()];

            if (QUOTE == charType)
            {

                appendQuotedString(pattern, pos, stripCustom, true);
                continue;

            }

            if (START_FE == charType)
            {

                fmtCount++;
                seekNonWs(pattern, pos);
                int start = pos.getIndex();
                int index = readArgumentIndex(pattern, next(pos));
                stripCustom.append(START_FE).append(index);
                seekNonWs(pattern, pos);
                Format format = null;
                String formatDescription = null;
                if (c[pos.getIndex()] == START_FMT)
                {
                    formatDescription = parseFormatDescription(pattern, next(pos));
                    format = getFormat(formatDescription);
                    if (format == null)
                    {
                        stripCustom.append(START_FMT).append(formatDescription);
                    }
                }
                foundFormats.add(format);
                foundDescriptions.add(format == null ? null : formatDescription);

                Preconditions.checkState(foundFormats.size() == fmtCount);
                Preconditions.checkState(foundDescriptions.size() == fmtCount);

                if (c[pos.getIndex()] != END_FE)
                {
                    throw new IllegalArgumentException("Unreadable format element at position " + start);
                }

            }

            //$FALL-THROUGH$
            stripCustom.append(c[pos.getIndex()]);
            next(pos);

        }

        super.applyPattern(stripCustom.toString());

        toPattern = insertFormats(super.toPattern(), foundDescriptions);

        if (containsElements(foundFormats))
        {
            Format[] origFormats = getFormats();
            // only loop over what we know we have, as MessageFormat on Java 1.3
            // seems to provide an extra format element:
            Iterator<Format> it = foundFormats.iterator();
            for (int i = 0; it.hasNext(); i++)
            {
                Format f = it.next();
                if (f != null)
                {
                    origFormats[i] = f;
                }
            }
            super.setFormats(origFormats);
        }

    }
301042
function _replaceRegExp(val) {
  const operatorRegex = /(::?|\[)/g;
  const newVal = (val.match(operatorRegex)) ? val.substring(0, val.search(operatorRegex)) : val;
  return _matchRegExp(newVal);
}
434416
public static String fixPropertyValue(String value) {
		// replace with predefined varialebls
		value = value.replaceAll("\\{jk.appname\\}", JK.getAppName());
		return value;
	}
623879
@Override
    public Object apply(Object value, Object... params) {

        String original = super.asString(value);

        Object needle = super.get(0, params);

        if (needle == null) {
            throw new RuntimeException("invalid pattern: " + needle);
        }

        return original.replaceFirst(Pattern.quote(String.valueOf(needle)), "");
    }
1057385
private String substituteProperty(String field) {
        if ( field != null ) {
            String property = null;
            Matcher matcher = PROPERTY_PATTERN.matcher(field);
            while (matcher.find()) {
                property = matcher.group(1);
            }

            if (property != null) {
                log.debug("Set property {} to {}", property, this.getMavenModel().getProperties().getProperty(property));
                return this.getMavenModel().getProperties().getProperty(property);
            } else {
                return field;
            }
        }

        return null;
    }
510392
function(properties) {
            var key, newKey,
                remapped = {},
                axisProps = this.filterPropsByRegex(properties, /(axisY|secondaryAxis|axisLabelsY|axisTitleY|gridLinesY)/);
            for(key in axisProps) {
                if(axisProps.hasOwnProperty(key)) {
                    if(!this.yAxisKeyIsTrumped(key, properties)) {
                        newKey = key.replace(/(axisY|secondaryAxis)/, "axis");
                        newKey = newKey.replace(/axisLabelsY/, "axisLabels");
                        newKey = newKey.replace(/axisTitleY/, "axisTitle");
                        newKey = newKey.replace(/gridLinesY/, "gridLines");
                        remapped[newKey] = axisProps[key];
                    }
                }
            }
            return remapped;
        }
1033268
public static PropertyKey fromString(String input) {
    // First try to parse it as default key
    PropertyKey key = DEFAULT_KEYS_MAP.get(input);
    if (key != null) {
      return key;
    }
    // Try to match input with alias
    key = DEFAULT_ALIAS_MAP.get(input);
    if (key != null) {
      return key;
    }
    // Try different templates and see if any template matches
    for (Template template : Template.values()) {
      key = template.getPropertyKey(input);
      if (key != null) {
        return key;
      }
    }
    throw new IllegalArgumentException(
        ExceptionMessage.INVALID_CONFIGURATION_KEY.getMessage(input));
  }
411250
private static boolean propMatchesPrefix(String prefix, String key) {
        return key.startsWith(prefix) && key.length() >= prefix.length();
    }
1008776
function(node, pattern) {
		if (!!node && (node.nodeType === 3) && pattern.exec(node.nodeValue)) {
			node.nodeValue = node.nodeValue.replace(pattern, '');
		}
	}
1037907
function replaceValuesWithVariableNames (variables, prefix) {
  const map = {}

  Object.keys(variables || {}).forEach((variableName) => {
    map[variableName] = `var(${formatVariableName(variableName, prefix)})`
  })

  return map
}
672256
def replace_fields(meta, patterns):
    
    for pattern in patterns:
        try:
            field, regex, subst, _ = pattern.split(pattern[-1])

            # TODO: Allow numerical indices, and "+" for append
            namespace = meta
            keypath = [i.replace('\0', '.') for i in field.replace('..', '\0').split('.')]
            for key in keypath[:-1]:
                namespace = namespace[key]

            namespace[keypath[-1]] = re.sub(regex, subst, namespace[keypath[-1]])
        except (KeyError, IndexError, TypeError, ValueError) as exc:
            raise error.UserError("Bad substitution '%s' (%s)!" % (pattern, exc))

    return meta
112353
public static String replaceAll(CharSequence content, Pattern pattern, String replacementTemplate) {
		if (StrUtil.isEmpty(content)) {
			return StrUtil.str(content);
		}

		final Matcher matcher = pattern.matcher(content);
		boolean result = matcher.find();
		if (result) {
			final Set<String> varNums = findAll(PatternPool.GROUP_VAR, replacementTemplate, 1, new HashSet<String>());
			final StringBuffer sb = new StringBuffer();
			do {
				String replacement = replacementTemplate;
				for (String var : varNums) {
					int group = Integer.parseInt(var);
					replacement = replacement.replace("$" + var, matcher.group(group));
				}
				matcher.appendReplacement(sb, escape(replacement));
				result = matcher.find();
			} while (result);
			matcher.appendTail(sb);
			return sb.toString();
		}
		return StrUtil.str(content);
	}
387332
function(property, camelCase) {
		var prefixed = self.prefix + property;

		return camelCase? StyleFix.camelCase(prefixed) : prefixed;
	}
498783
def substitute_vars(template, replacements):
    
    result = template
    for (key, value) in replacements:
        result = result.replace('${' + key + '}' , value)
    if '${' in result:
        logging.warning("A variable was not replaced in '%s'.", result)
    return result
62823
function replace (obj, key, val) {
  if (obj.hasOwnProperty(key)) obj[key] = val;
  return obj;
}