当前位置: 首页>>代码示例>>Java>>正文


Java Matcher.quoteReplacement方法代码示例

本文整理汇总了Java中java.util.regex.Matcher.quoteReplacement方法的典型用法代码示例。如果您正苦于以下问题:Java Matcher.quoteReplacement方法的具体用法?Java Matcher.quoteReplacement怎么用?Java Matcher.quoteReplacement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.regex.Matcher的用法示例。


在下文中一共展示了Matcher.quoteReplacement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeMacro

import java.util.regex.Matcher; //导入方法依赖的package包/类
public String executeMacro(TeXParser tp, String[] args) {
	String code = macrocode.get(args[0]);
	String rep;
	int nbargs = args.length - 11;
	int dec = 0;

	if (args[nbargs + 1] != null) {
		dec = 1;
		rep = Matcher.quoteReplacement(args[nbargs + 1]);
		code = code.replaceAll("#1", rep);
	} else if (macroreplacement.get(args[0]) != null) {
		dec = 1;
		rep = Matcher.quoteReplacement(macroreplacement.get(args[0]));
		code = code.replaceAll("#1", rep);
	}

	for (int i = 1; i <= nbargs; i++) {
		rep = Matcher.quoteReplacement(args[i]);
		code = code.replaceAll("#" + (i + dec), rep);
	}

	return code;
}
 
开发者ID:daquexian,项目名称:FlexibleRichTextView,代码行数:24,代码来源:NewCommandMacro.java

示例2: pattern

import java.util.regex.Matcher; //导入方法依赖的package包/类
/** Return a representation of the pattern used by this instance for formatting and
 *  parsing.  The format is similar to, but not the same as the format recognized by the
 *  {@link Builder#pattern} and {@link Builder#localizedPattern} methods.  The pattern
 *  returned by this method is localized, any currency signs expressed are literally, and
 *  optional fractional decimal places are shown grouped in parentheses. */
public String pattern() { synchronized(numberFormat) {
    StringBuilder groups = new StringBuilder();
    for (int group : decimalGroups) {
        groups.append("(").append(Strings.repeat("#", group)).append(")");
    }
    DecimalFormatSymbols s = numberFormat.getDecimalFormatSymbols();
    String digit = String.valueOf(s.getDigit());
    String exp = s.getExponentSeparator();
    String groupSep = String.valueOf(s.getGroupingSeparator());
    String moneySep = String.valueOf(s.getMonetaryDecimalSeparator());
    String zero = String.valueOf(s.getZeroDigit());
    String boundary = String.valueOf(s.getPatternSeparator());
    String minus = String.valueOf(s.getMinusSign());
    String decSep = String.valueOf(s.getDecimalSeparator());

    String prefixAndNumber = "(^|" + boundary+ ")" +
        "([^" + Matcher.quoteReplacement(digit + zero + groupSep + decSep + moneySep) + "']*('[^']*')?)*" +
        "[" + Matcher.quoteReplacement(digit + zero + groupSep + decSep + moneySep + exp) + "]+";

    return numberFormat.toLocalizedPattern().
        replaceAll(prefixAndNumber, "$0" + groups.toString()).
           replaceAll("¤¤", Matcher.quoteReplacement(coinCode())).
           replaceAll("¤", Matcher.quoteReplacement(coinSymbol()));
}}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:30,代码来源:BtcFormat.java

示例3: expandUriComponent

import java.util.regex.Matcher; //导入方法依赖的package包/类
static String expandUriComponent(String source, UriTemplateVariables uriVariables) {
	if (source == null) {
		return null;
	}
	if (source.indexOf('{') == -1) {
		return source;
	}
	Matcher matcher = NAMES_PATTERN.matcher(source);
	StringBuffer sb = new StringBuffer();
	while (matcher.find()) {
		String match = matcher.group(1);
		String variableName = getVariableName(match);
		Object variableValue = uriVariables.getValue(variableName);
		if (UriTemplateVariables.SKIP_VALUE.equals(variableValue)) {
			continue;
		}
		String variableValueString = getVariableValueAsString(variableValue);
		String replacement = Matcher.quoteReplacement(variableValueString);
		matcher.appendReplacement(sb, replacement);
	}
	matcher.appendTail(sb);
	return sb.toString();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:UriComponents.java

示例4: run

import java.util.regex.Matcher; //导入方法依赖的package包/类
public boolean run() {
    String filter = arguments.getFilter();
    if (filter == null) {
        System.err.println("Please check your filter!");
        return false;
    }

    String replacement = Matcher.quoteReplacement(File.separator);
    String searchString = Pattern.quote(".");
    filterAsPath = filter.replaceAll(searchString, replacement);
    File projectFolder = getProjectFolder();
    if (projectFolder.exists()) {
        traverseSmaliCode(projectFolder);
        return true;
    } else if (isInstantRunEnabled()) {
        System.err.println("Enabled Instant Run feature detected. We cannot decompile it. Please, disable Instant Run and rebuild your app.");
        Messages.showInfoMessage(Strings.ERROR_INSTANT_RUN_ENABLED, Strings.TITLE_ERROR_INSTANT_RUN_ENABLED);
    } else {
        System.err.println("Smali folder cannot be absent!");
    }
    return false;
}
 
开发者ID:kaygisiz,项目名称:Dependency-Injection-Graph,代码行数:23,代码来源:SmaliAnalyzer.java

示例5: replaceAll

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static Integer replaceAll(Object orig_value_obj, Object repl_obj, Object ere_obj, StringBuffer sb, String convfmt) {
	String orig_value = toAwkString(orig_value_obj, convfmt);
	String repl = toAwkString(repl_obj, convfmt);
	String ere = toAwkString(ere_obj, convfmt);
	// remove special meaning for backslash and dollar signs
	repl = Matcher.quoteReplacement(repl);
	sb.setLength(0);

	Pattern p = Pattern.compile(ere);
	Matcher m = p.matcher(orig_value);
	int cnt = 0;
	while (m.find()) {
		++cnt;
		m.appendReplacement(sb, repl);
	}
	m.appendTail(sb);
	return Integer.valueOf(cnt);
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:19,代码来源:JRT.java

示例6: inject

import java.util.regex.Matcher; //导入方法依赖的package包/类
static public String inject(Matcher matcher, String injection) {
	if (matcher.find()) {
		injection = Matcher.quoteReplacement(injection);
		StringBuffer sb = new StringBuffer();
		String sub = matcher.group();
		int id = matcher.start(1) - matcher.start();
		String sub_start = sub.substring(0, id);
		String sub_end = sub.substring(id, sub.length());
		sub = sub_start + injection + sub_end;
		matcher.appendReplacement(sb, sub);
		matcher.appendTail(sb);
		return sb.toString();
	}
	return null;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:16,代码来源:RegexpUtils.java

示例7: replaceFirst

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static Integer replaceFirst(Object orig_value_obj, Object repl_obj, Object ere_obj, StringBuffer sb, String convfmt) {
	String orig_value = toAwkString(orig_value_obj, convfmt);
	String repl = toAwkString(repl_obj, convfmt);
	String ere = toAwkString(ere_obj, convfmt);
	// remove special meaning for backslash and dollar signs
	repl = Matcher.quoteReplacement(repl);
	sb.setLength(0);
	sb.append(orig_value.replaceFirst(ere, repl));
	if (sb.toString().equals(orig_value)) {
		return ZERO;
	} else {
		return ONE;
	}
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:15,代码来源:JRT.java

示例8: shortenClassNames

import java.util.regex.Matcher; //导入方法依赖的package包/类
static String shortenClassNames(String s) {
	Matcher m = Pattern.compile("<(.*?): (.*?)>").matcher(s);
	if (m.find()) {
		String className = m.group(1);
		String shortenedClassName = shorten(className);
		String replacement = '<' + shortenedClassName + ": " + m.group(2) + '>';
		String escapedReplacement = Matcher.quoteReplacement(replacement);
		s = m.replaceAll(escapedReplacement);
	}
	return s;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:12,代码来源:ValueFormatter.java

示例9: toSQL

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Returns a {@code String} with a SQL with parameters replaced with values.
 * 
 * @since 1.1.0
 * @return a {@code String} with a SQL.
 */
public String toSQL()
{
	String sql = build();
	for (Entry<String, Object> entry : parametersMap.entrySet())
	{
		String param = Matcher.quoteReplacement(entry.getKey());
		sql = sql.replaceAll(":" + param + "(?=[\\s\\)])", valueToSQLString(entry.getValue()));
	}
	return sql;
}
 
开发者ID:iaunzu,项目名称:strqlbuilder,代码行数:17,代码来源:StrQLBuilder.java

示例10: relativePath

import java.util.regex.Matcher; //导入方法依赖的package包/类
private static String relativePath(Path filePath, Path modulesFolder) {
  String folderString = Matcher.quoteReplacement(modulesFolder.toString() + File.separator);
  return filePath.toString().replaceFirst(folderString, "").replaceFirst(".json", "")
      .replace("\\", "/");
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:6,代码来源:Graphviz.java

示例11: substitute

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Given a static config map, substitute occurrences of ${TWISTER2_*} variables
 * in the provided path string
 *
 * @param config a static map config object of key value pairs
 * @param pathString string representing a path including ${TWISTER2_*} variables
 * @return String string that represents the modified path
 */
public static String substitute(Config config, String pathString,
                                Map<String, ConfigEntry> substitutes) {

  // trim the leading and trailing spaces
  String trimmedPath = pathString.trim();

  if (isURL(trimmedPath)) {
    return substituteURL(config, trimmedPath, substitutes);
  }

  // get platform independent file separator
  String fileSeparator = Matcher.quoteReplacement(File.separator);

  // split the trimmed path into a list of components
  List<String> fixedList = Arrays.asList(trimmedPath.split(fileSeparator));
  List<String> list = new LinkedList<>(fixedList);

  // substitute various variables
  for (int i = 0; i < list.size(); i++) {
    String elem = list.get(i);

    if ("${HOME}".equals(elem) || "~".equals(elem)) {
      list.set(i, System.getProperty("user.home"));

    } else if ("${JAVA_HOME}".equals(elem)) {
      String javaPath = System.getenv("JAVA_HOME");
      if (javaPath != null) {
        list.set(i, javaPath);
      }
    } else if (isToken(elem)) {
      Matcher m = TOKEN_PATTERN.matcher(elem);
      if (m.matches()) {
        String token = m.group(1);
        try {
          ConfigEntry entry = substitutes.get(token);
          if (entry == null) {
            LOG.warning("We cannot find the substitution entry for token: " + token);
            continue;
          }
          String value = config.getStringValue(entry.getKey());
          if (value == null) {
            throw new IllegalArgumentException(String.format("Config value %s contains "
                    + "substitution token %s but the corresponding config setting %s not found",
                pathString, elem, entry.getKey()));
          }
          list.set(i, value);
        } catch (IllegalArgumentException e) {
          LOG.warning(String.format("Config value %s contains substitution token %s which is "
                  + "not defined in the Key enum, which is required for token substitution",
              pathString, elem));
        }
      }
    }
  }

  return combinePaths(list);
}
 
开发者ID:DSC-SPIDAL,项目名称:twister2,代码行数:66,代码来源:TokenSub.java

示例12: getEscapedClientCode

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * @return the escaped class client Id formatted to be displayed on a HTML.
 */
public String getEscapedClientCode()
{
	return Matcher.quoteReplacement(getClientCode());
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:8,代码来源:ClassInfo.java

示例13: renderDiffModule

import java.util.regex.Matcher; //导入方法依赖的package包/类
private String renderDiffModule(String bodyTemplate, Env env, ReleaseHistoryBO releaseHistory) {
  String appId = releaseHistory.getAppId();
  String namespaceName = releaseHistory.getNamespaceName();

  AppNamespace appNamespace = appNamespaceService.findByAppIdAndName(appId, namespaceName);
  if (appNamespace == null) {
    appNamespace = appNamespaceService.findPublicAppNamespace(namespaceName);
  }

  //don't show diff content if namespace's format is file
  if (appNamespace == null ||
          !appNamespace.getFormat().equals(ConfigFileFormat.Properties.getValue())) {

    return bodyTemplate.replaceAll(EMAIL_CONTENT_DIFF_MODULE, "<br><h4>变更内容请点击链接到Apollo上查看</h4>");
  }

  ReleaseCompareResult result = getReleaseCompareResult(env, releaseHistory);

  if (!result.hasContent()) {
    return bodyTemplate.replaceAll(EMAIL_CONTENT_DIFF_MODULE, "<br><h4>无配置变更</h4>");
  }

  List<Change> changes = result.getChanges();
  StringBuilder changesHtmlBuilder = new StringBuilder();
  for (Change change : changes) {
    String key = change.getEntity().getFirstEntity().getKey();
    String oldValue = change.getEntity().getFirstEntity().getValue();
    String newValue = change.getEntity().getSecondEntity().getValue();
    newValue = newValue == null ? "" : newValue;

    changesHtmlBuilder.append("<tr>");
    changesHtmlBuilder.append("<td width=\"10%\">").append(change.getType().toString()).append("</td>");
    changesHtmlBuilder.append("<td width=\"20%\">").append(cutOffString(key)).append("</td>");
    changesHtmlBuilder.append("<td width=\"35%\">").append(cutOffString(oldValue)).append("</td>");
    changesHtmlBuilder.append("<td width=\"35%\">").append(cutOffString(newValue)).append("</td>");

    changesHtmlBuilder.append("</tr>");
  }

  String diffContent = Matcher.quoteReplacement(changesHtmlBuilder.toString());
  String diffModuleTemplate = getDiffModuleTemplate();
  String diffModuleRenderResult = diffModuleTemplate.replaceAll(EMAIL_CONTENT_FIELD_DIFF_CONTENT, diffContent);
  return bodyTemplate.replaceAll(EMAIL_CONTENT_DIFF_MODULE, diffModuleRenderResult);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:45,代码来源:ConfigPublishEmailBuilder.java

示例14: MCSubTitle

import java.util.regex.Matcher; //导入方法依赖的package包/类
public MCSubTitle(Localizer localizer, String message) {
	super(localizer, Matcher.quoteReplacement(message));
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:4,代码来源:MCSubTitle.java

示例15: interpolateParameter

import java.util.regex.Matcher; //导入方法依赖的package包/类
private String interpolateParameter(final Locale locale, final String message, final Parameter parameter) {
	String replaceRegex = this.getInterpolationReplaceRegex(parameter.getName());
	String formattedValue =  Matcher.quoteReplacement(parameter.getFormattedValue(locale));
	return message.replaceAll(replaceRegex, formattedValue);
}
 
开发者ID:rooting-company,项目名称:roxana,代码行数:6,代码来源:Translator.java


注:本文中的java.util.regex.Matcher.quoteReplacement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。