java.util.regex.Matcher.toString()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(126)

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

Matcher.toString介绍

[英]Returns a string representing this Matcher. The format of this string is unspecified.
[中]返回表示此匹配器的字符串。此字符串的格式未指定。

代码示例

代码示例来源:origin: apache/hive

private void addFileToMap(Matcher matcher, Path file, boolean sawBase,
             Map<Integer, BucketTracker> splitToBucketMap) {
 if (!matcher.find()) {
  String msg = "Found a non-bucket file that we thought matched the bucket pattern! " +
   file.toString() + " Matcher=" + matcher.toString();
  LOG.error(msg);
  //following matcher.group() would fail anyway and we don't want to skip files since that
  //may be a data loss scenario
  throw new IllegalArgumentException(msg);
 }
 int bucketNum = Integer.parseInt(matcher.group());
 BucketTracker bt = splitToBucketMap.get(bucketNum);
 if (bt == null) {
  bt = new BucketTracker();
  splitToBucketMap.put(bucketNum, bt);
 }
 LOG.debug("Adding " + file.toString() + " to list of files for splits");
 bt.buckets.add(file);
 bt.sawBase |= sawBase;
}

代码示例来源:origin: apache/drill

private void addFileToMap(Matcher matcher, Path file, boolean sawBase,
             Map<Integer, BucketTracker> splitToBucketMap) {
 if (!matcher.find()) {
  LOG.warn("Found a non-bucket file that we thought matched the bucket pattern! " +
    file.toString() + " Matcher=" + matcher.toString());
 }
 int bucketNum = Integer.parseInt(matcher.group());
 BucketTracker bt = splitToBucketMap.get(bucketNum);
 if (bt == null) {
  bt = new BucketTracker();
  splitToBucketMap.put(bucketNum, bt);
 }
 LOG.debug("Adding " + file.toString() + " to list of files for splits");
 bt.buckets.add(file);
 bt.sawBase |= sawBase;
}

代码示例来源:origin: kite-sdk/kite

public String toString() {
    return matcher.toString();
  }
}

代码示例来源:origin: sonia.regexp/named-regexp

public String toString() {
  return matcher.toString();
}

代码示例来源:origin: org.kitesdk/kite-morphlines-core

public String toString() {
    return matcher.toString();
  }
}

代码示例来源:origin: net.loomchild/segment

public String toString() {
  return "ReaderMatcher: " + matcher.toString();
}

代码示例来源:origin: dhanji/loop

public String toString() {
 return matcher.toString();
}

代码示例来源:origin: codice/ddf

public String toString() {
 return String.format("TimeLimitedMatcher of [%s]", matcher.toString());
}

代码示例来源:origin: hdiv/hdiv

protected boolean execPattern(final String input) {
  Matcher matcher = pattern.matcher(input);
  try {
    return matcher.matches();
  }
  catch (Throwable e) {
    log.error("Error matching pattern " + matcher.toString() + " with value " + input, e);
  }
  return false;
}

代码示例来源:origin: stackoverflow.com

public class Main {
  private static final String REGEX = "\\[([^\\]]+)";
  private static final String INPUT = "10:11:22 [UTP][ROX][ID:32424][APP STR]";

  private static Pattern pattern;
  private static Matcher matcher;

  public static void main(String[] args) {
    Pattern pattern = Pattern.compile(REGEX);
    Matcher matcher = pattern.matcher(INPUT);

    while (matcher.find()) {
      System.out.println(matcher.toString());
    }
  }
}

代码示例来源:origin: stackoverflow.com

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TCPChat {

 static public void main(String[] args) {
  String url = "<img src=\"http://stackoverflow.com/a/b/c/d/someimage.jpg\">";
  Pattern p = Pattern.compile("<img src=\"http://stackoverflow.com/.*jpg\">");
  // Create a matcher with an input string
  Matcher m = p.matcher(url);
  while (m.find()) {
   String s = m.toString();
   System.out.println(s);
  }
 }
}

代码示例来源:origin: stackoverflow.com

Matcher base = Pattern.compile("\\bred\\b|\\bgreen\\b|\\bblue\\b|[+()]{1}").matcher(input.trim());
while (!base.hitEnd()) {
  if (base.find()) {
   String s = base.group();
   System.out.println("Found: " + s);
   output += String.format(" %s", s);
  }
} 
if (output.isEmpty()) {
  throw new IllegalArgumentException("Invalid input no matching tokens found! " + base.toString());
}

代码示例来源:origin: com.evasion/Plugin-Common

/**
 * Recherhce l'ensemble des clé dans le template.
 * @param templateText le template à traiter.
 * @return la map des clés trouvé.
 */
protected Map<String, Set<String>> findKey(String templateText) {
  Map<String, Set<String>> result = new HashMap<String, Set<String>>();
  //Pattern keyTemplate = Pattern.compile(START_PATTERN + "(.*?)" + END_PATTERN);
  Pattern keyTemplate = Pattern.compile(FIND_PATTERN);
  Matcher tagmatch = keyTemplate.matcher(templateText);
  LOGGER.debug("Matcher généré: {} - {}", tagmatch.toString(), templateText);
  //LOGGER.debug("find: {}", tagmatch.find());
    while (tagmatch.find()) {
      LOGGER.debug("groupe: {}", tagmatch.group(2));
      String key = StringUtils.substringBefore(tagmatch.group(2), SEPARATOR);
      String ext = StringUtils.substringAfter(tagmatch.group(2), SEPARATOR);
      if (result.containsKey(key)) {
        ((HashSet) result.get(key)).add(ext);
      } else {
        Set<String> set = new HashSet<String>();
        set.add(ext);
        result.put(key, set);
      }
    }
  LOGGER.debug("End find key.");
  return result;
}

代码示例来源:origin: io.hops/hadoop-mapreduce-client-core

/** Construct a TaskID object from given string 
 * @return constructed TaskID object or null if the given String is null
 * @throws IllegalArgumentException if the given string is malformed
 */
public static TaskID forName(String str) 
 throws IllegalArgumentException {
 if(str == null)
  return null;
 Matcher m = taskIdPattern.matcher(str);
 if (m.matches()) {
  return new org.apache.hadoop.mapred.TaskID(m.group(1),
    Integer.parseInt(m.group(2)),
    CharTaskTypeMaps.getTaskType(m.group(3).charAt(0)),
    Integer.parseInt(m.group(4)));
 }
 String exceptionMsg = "TaskId string : " + str + " is not properly formed" +
   "\nReason: " + m.toString();
 throw new IllegalArgumentException(exceptionMsg);
}
/**

代码示例来源:origin: org.tuckey/urlrewritefilter

log.error("group count on function finder regex is not as expected");
if (log.isDebugEnabled()) {
  log.error("functionMatcher: " + functionMatcher.toString());

代码示例来源:origin: paultuckey/urlrewritefilter

log.error("group count on function finder regex is not as expected");
if (log.isDebugEnabled()) {
  log.error("functionMatcher: " + functionMatcher.toString());

代码示例来源:origin: paultuckey/urlrewritefilter

log.error("group count on variable finder regex is not as expected");
if (log.isDebugEnabled()) {
  log.error("variableMatcher: " + variableMatcher.toString());

代码示例来源:origin: org.tuckey/urlrewritefilter

log.error("group count on backref finder regex is not as expected");
if (log.isDebugEnabled()) {
  log.error("varMatcher: " + varMatcher.toString());

代码示例来源:origin: paultuckey/urlrewritefilter

log.error("group count on backref finder regex is not as expected");
if (log.isDebugEnabled()) {
  log.error("varMatcher: " + varMatcher.toString());

代码示例来源:origin: paultuckey/urlrewritefilter

log.error("group count on backref finder regex is not as expected");
if (log.isDebugEnabled()) {
  log.error("backRefMatcher: " + backRefMatcher.toString());

相关文章