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

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

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

Matcher.usePattern介绍

[英]Sets a new pattern for the Matcher. Results of a previous find get lost. The next attempt to find an occurrence of the Patternin the string will start at the beginning of the input.
[中]为匹配器设置新模式。以前查找的结果将丢失。下一次在字符串中查找模式匹配项的尝试将从输入的开头开始。

代码示例

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

/**
 * Creates a matcher for a given combination of pattern and input. Both
 * elements can be changed later on.
 *
 * @param pattern
 *            the pattern to use.
 * @param input
 *            the input to use.
 */
Matcher(Pattern pattern, CharSequence input) {
  usePattern(pattern);
  reset(input);
}

代码示例来源:origin: square/okhttp

matcher.region(pos, end);
if (hour == -1 && matcher.usePattern(TIME_PATTERN).matches()) {
 hour = Integer.parseInt(matcher.group(1));
 minute = Integer.parseInt(matcher.group(2));
 second = Integer.parseInt(matcher.group(3));
} else if (dayOfMonth == -1 && matcher.usePattern(DAY_OF_MONTH_PATTERN).matches()) {
 dayOfMonth = Integer.parseInt(matcher.group(1));
} else if (month == -1 && matcher.usePattern(MONTH_PATTERN).matches()) {
 String monthString = matcher.group(1).toLowerCase(Locale.US);
 month = MONTH_PATTERN.pattern().indexOf(monthString) / 4; // Sneaky! jan=1, dec=12.
} else if (year == -1 && matcher.usePattern(YEAR_PATTERN).matches()) {
 year = Integer.parseInt(matcher.group(1));

代码示例来源:origin: osmandapp/Osmand

/**
 * Skip over any whitespace so that the matcher region starts at the next
 * token.
 */
private void skipWhitespace() {
 matcher.usePattern(WHITESPACE);
 if (matcher.lookingAt()) {
  matcher.region(matcher.end(), matcher.regionEnd());
 }
}

代码示例来源:origin: com.google.protobuf/protobuf-java

/**
 * Skip over any whitespace so that the matcher region starts at the next
 * token.
 */
private void skipWhitespace() {
 matcher.usePattern(WHITESPACE);
 if (matcher.lookingAt()) {
  matcher.region(matcher.end(), matcher.regionEnd());
 }
}

代码示例来源:origin: prestodb/presto

matcher.region(pos, end);
if (hour == -1 && matcher.usePattern(TIME_PATTERN).matches()) {
 hour = Integer.parseInt(matcher.group(1));
 minute = Integer.parseInt(matcher.group(2));
 second = Integer.parseInt(matcher.group(3));
} else if (dayOfMonth == -1 && matcher.usePattern(DAY_OF_MONTH_PATTERN).matches()) {
 dayOfMonth = Integer.parseInt(matcher.group(1));
} else if (month == -1 && matcher.usePattern(MONTH_PATTERN).matches()) {
 String monthString = matcher.group(1).toLowerCase(Locale.US);
 month = MONTH_PATTERN.pattern().indexOf(monthString) / 4; // Sneaky! jan=1, dec=12.
} else if (year == -1 && matcher.usePattern(YEAR_PATTERN).matches()) {
 year = Integer.parseInt(matcher.group(1));

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

Pattern badflag = Pattern.compile("[a-z]+", 0xaaaaaa);
Matcher am = okpat.matcher("hello, world");
am.usePattern(okpat);
am.usePattern(null);
try {
  String uee = new String(new byte[] { 'a', 'b' }, "unkown charset");

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

"' - it looks like an index name, which is not allowed." );
  matcher.usePattern( PATTERN_INDEX_NAME_END );
  if ( matcher.find() )
matcher.usePattern( PATTERN_PROPERTY_CLAUSE_BEGIN );
if ( !matcher.find() )
matcher.usePattern( PATTERN_FIRST_PROPERTY );
if ( !matcher.find() )
  if ( matcher.pattern() != PATTERN_FOLLOWING_PROPERTY )
    matcher.usePattern( PATTERN_FOLLOWING_PROPERTY );
matcher.usePattern( PATTERN_PROPERTY_CLAUSE_END );
if ( !matcher.find() )

代码示例来源:origin: com.squareup.okhttp3/okhttp

matcher.region(pos, end);
if (hour == -1 && matcher.usePattern(TIME_PATTERN).matches()) {
 hour = Integer.parseInt(matcher.group(1));
 minute = Integer.parseInt(matcher.group(2));
 second = Integer.parseInt(matcher.group(3));
} else if (dayOfMonth == -1 && matcher.usePattern(DAY_OF_MONTH_PATTERN).matches()) {
 dayOfMonth = Integer.parseInt(matcher.group(1));
} else if (month == -1 && matcher.usePattern(MONTH_PATTERN).matches()) {
 String monthString = matcher.group(1).toLowerCase(Locale.US);
 month = MONTH_PATTERN.pattern().indexOf(monthString) / 4; // Sneaky! jan=1, dec=12.
} else if (year == -1 && matcher.usePattern(YEAR_PATTERN).matches()) {
 year = Integer.parseInt(matcher.group(1));

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

checkOpen();
matcher.usePattern(LINE_PATTERN);
matcher.region(findStartIndex, bufferLength);

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

private boolean setTokenRegion() {
  // The position where token begins
  int tokenStartIndex = 0;
  // The position where token ends
  int tokenEndIndex = 0;
  // Use delimiter pattern
  matcher.usePattern(delimiter);
  matcher.region(findStartIndex, bufferLength);
  tokenStartIndex = findPreDelimiter();
  if (setHeadTokenRegion(tokenStartIndex)) {
    return true;
  }
  tokenEndIndex = findDelimiterAfter();
  // If the second delimiter is not found
  if (tokenEndIndex == -1) {
    // Just first Delimiter Exists
    if (findStartIndex == bufferLength) {
      return false;
    }
    tokenEndIndex = bufferLength;
    findStartIndex = bufferLength;
  }
  matcher.region(tokenStartIndex, tokenEndIndex);
  return true;
}

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

int horizonLineSeparator = 0;
matcher.usePattern(MULTI_LINE_TERMINATOR);
matcher.region(findStartIndex, bufferLength);
matcher.usePattern(pattern);

代码示例来源:origin: osmandapp/Osmand

matcher.usePattern(TOKEN);
if (matcher.lookingAt()) {
 currentToken = matcher.group();

代码示例来源:origin: com.google.protobuf/protobuf-java

matcher.usePattern(TOKEN);
if (matcher.lookingAt()) {
 currentToken = matcher.group();

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

checkOpen();
checkNotNull(pattern);
matcher.usePattern(pattern);
matcher.region(findStartIndex, bufferLength);
while (true) {

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

throw new IllegalArgumentException("horizon < 0");
matcher.usePattern(pattern);

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

matcher.usePattern(pattern);
if (!matcher.matches()) {
  recoverPreviousStatus();

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

return false;
matcher.usePattern(pattern);
boolean hasNext = false;

代码示例来源:origin: palantir/atlasdb

/**
 * Skip over any whitespace so that the matcher region starts at the next token.
 */
private void skipWhitespace() {
  matcher.usePattern(WHITESPACE);
  if (matcher.lookingAt()) {
    matcher.region(matcher.end(), matcher.regionEnd());
  }
}

代码示例来源:origin: palantir/atlasdb

matcher.usePattern(TOKEN);
if (matcher.lookingAt()) {
  currentToken = matcher.group();

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

for (Rule r : rules)
 if (m.usePattern(r.pattern).lookingAt())

相关文章