org.apache.oro.text.regex.Util.substitute()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(637)

本文整理了Java中org.apache.oro.text.regex.Util.substitute()方法的一些代码示例,展示了Util.substitute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.substitute()方法的具体详情如下:
包路径:org.apache.oro.text.regex.Util
类名称:Util
方法名:substitute

Util.substitute介绍

暂无

代码示例

代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core

  1. public String substitute(String line)
  2. {
  3. return org.apache.oro.text.regex.Util.substitute(getMatcher(), getPattern(), this, line,
  4. org.apache.oro.text.regex.Util.SUBSTITUTE_ALL);
  5. }

代码示例来源:origin: org.apache.ant/ant-apache-oro

  1. new Perl5Substitution(subst.toString(),
  2. Perl5Substitution.INTERPOLATE_ALL);
  3. return Util.substitute(matcher,
  4. getCompiledPattern(options),
  5. s,

代码示例来源:origin: com.atlassian.jira/jira-api

  1. /** Equivalent of JDK 1.4's {@link String#replaceAll(String regex, String replacement)}, usable in JDK 1.3
  2. *
  3. * @param str The string to apply operations to
  4. * @param regex The regex that str should match
  5. * @param replacement String to replace matched string with (using $1, $2 etc for substitutions).
  6. * @return A modified version of str, or null if the regexp was invalid
  7. */
  8. public static String replaceAll(final String str, String regex, String replacement)
  9. {
  10. Pattern pattern;
  11. try
  12. {
  13. pattern = new Perl5Compiler().compile(regex);
  14. }
  15. catch (MalformedPatternException e)
  16. {
  17. log.error("Error parsing regexp '"+regex+"' - "+e, e);
  18. return null;
  19. }
  20. return Util.substitute(new Perl5Matcher(), pattern, new Perl5Substitution(replacement), str, Util.SUBSTITUTE_ALL);
  21. // return str.replaceAll(regex, replacement);
  22. }

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_components

  1. private String filterString(final String content) {
  2. if (stringsToSkip == null || stringsToSkip.isEmpty()) {
  3. return content;
  4. } else {
  5. String result = content;
  6. for (SubstitutionElement regex : stringsToSkip) {
  7. emptySub.setSubstitution(regex.getSubstitute());
  8. result = Util.substitute(JMeterUtils.getMatcher(), JMeterUtils.getPatternCache().getPattern(regex.getRegex()),
  9. emptySub, result, Util.SUBSTITUTE_ALL);
  10. }
  11. return result;
  12. }
  13. }

代码示例来源:origin: org.apache.jmeter/ApacheJMeter_core

  1. @Override
  2. public JMeterProperty transformValue(JMeterProperty prop) throws InvalidVariableException {
  3. PatternMatcher pm = JMeterUtils.getMatcher();
  4. PatternCompiler compiler = new Perl5Compiler();
  5. String input = prop.getStringValue();
  6. if(input == null) {
  7. return prop;
  8. }
  9. for(Entry<String, String> entry : getVariables().entrySet()){
  10. String key = entry.getKey();
  11. String value = entry.getValue();
  12. if (regexMatch) {
  13. try {
  14. Pattern pattern = compiler.compile(constructPattern(value));
  15. input = Util.substitute(pm, pattern,
  16. new StringSubstitution(FUNCTION_REF_PREFIX + key + FUNCTION_REF_SUFFIX),
  17. input, Util.SUBSTITUTE_ALL);
  18. } catch (MalformedPatternException e) {
  19. log.warn("Malformed pattern: {}", value);
  20. }
  21. } else {
  22. input = StringUtilities.substitute(input, value, FUNCTION_REF_PREFIX + key + FUNCTION_REF_SUFFIX);
  23. }
  24. }
  25. return new StringProperty(prop.getName(), input);
  26. }

代码示例来源:origin: com.bbossgroups/bboss-util

  1. if(sets.size() > 0)
  2. newsrc = Util.substitute(matcher, pattern, new Perl5Substitution(substitution),
  3. src, Util.SUBSTITUTE_ALL);

代码示例来源:origin: org.w3c.jigsaw/jigsaw

  1. if (matcher.matches(requrl, pat[i])) {
  2. Substitution s = new Perl5Substitution(sub[i]);
  3. result = Util.substitute(matcher, pat[i], s, requrl,
  4. Util.SUBSTITUTE_ALL);
  5. break;

代码示例来源:origin: com.bbossgroups/bboss-util

  1. if(sets.size() > 0)
  2. newsrc = Util.substitute(matcher, pattern, new Perl5Substitution(substitution),
  3. src, Util.SUBSTITUTE_ALL);

代码示例来源:origin: com.bbossgroups/bboss-util

  1. public static String replaceAll(String val, String str1, String str2,
  2. int mask) {
  3. String patternStr = str1;
  4. /**
  5. * 编译正则表达式patternStr,并用该表达式与传入的sql语句进行模式匹配,
  6. * 如果匹配正确,则从匹配对象中提取出以上定义好的6部分,存放到数组中并返回 该数组
  7. */
  8. PatternCompiler compiler = new Perl5Compiler();
  9. Pattern pattern = null;
  10. try {
  11. pattern = compiler.compile(patternStr,
  12. mask);
  13. PatternMatcher matcher = new Perl5Matcher();
  14. return org.apache.oro.text.regex.Util.substitute(matcher, pattern,
  15. new StringSubstitution(str2), val,
  16. org.apache.oro.text.regex.Util.SUBSTITUTE_ALL);
  17. } catch (MalformedPatternException e) {
  18. e.printStackTrace();
  19. return val;
  20. }
  21. }

代码示例来源:origin: com.bbossgroups/bboss-util

  1. public static String replaceFirst(String val, String str1, String str2,
  2. boolean CASE_INSENSITIVE) {
  3. String patternStr = str1;
  4. /**
  5. * 编译正则表达式patternStr,并用该表达式与传入的sql语句进行模式匹配,
  6. * 如果匹配正确,则从匹配对象中提取出以上定义好的6部分,存放到数组中并返回 该数组
  7. */
  8. PatternCompiler compiler = new Perl5Compiler();
  9. Pattern pattern = null;
  10. try {
  11. if (CASE_INSENSITIVE) {
  12. pattern = compiler.compile(patternStr,
  13. Perl5Compiler.DEFAULT_MASK);
  14. } else {
  15. pattern = compiler.compile(patternStr,
  16. Perl5Compiler.CASE_INSENSITIVE_MASK);
  17. }
  18. PatternMatcher matcher = new Perl5Matcher();
  19. return org.apache.oro.text.regex.Util.substitute(matcher, pattern,
  20. new StringSubstitution(str2), val);
  21. } catch (MalformedPatternException e) {
  22. e.printStackTrace();
  23. return val;
  24. }
  25. }

代码示例来源:origin: com.bbossgroups/bboss-util

  1. public static String replaceAll(String val, String str1, String str2,
  2. boolean CASE_INSENSITIVE) {
  3. String patternStr = str1;
  4. /**
  5. * 编译正则表达式patternStr,并用该表达式与传入的sql语句进行模式匹配,
  6. * 如果匹配正确,则从匹配对象中提取出以上定义好的6部分,存放到数组中并返回 该数组
  7. */
  8. PatternCompiler compiler = new Perl5Compiler();
  9. Pattern pattern = null;
  10. try {
  11. if (CASE_INSENSITIVE) {
  12. pattern = compiler.compile(patternStr,
  13. Perl5Compiler.DEFAULT_MASK);
  14. } else {
  15. pattern = compiler.compile(patternStr,
  16. Perl5Compiler.CASE_INSENSITIVE_MASK);
  17. }
  18. PatternMatcher matcher = new Perl5Matcher();
  19. return org.apache.oro.text.regex.Util.substitute(matcher, pattern,
  20. new StringSubstitution(str2), val,
  21. org.apache.oro.text.regex.Util.SUBSTITUTE_ALL);
  22. } catch (MalformedPatternException e) {
  23. e.printStackTrace();
  24. return val;
  25. }
  26. }

相关文章

Util类方法