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


Java Matcher.find方法代码示例

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


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

示例1: camel2Underline

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static String camel2Underline(String fieldName) {
    if(fieldName == null||"".equals(fieldName)){
        return "";
    }
    fieldName = String.valueOf(fieldName.charAt(0)).toUpperCase().concat(fieldName.substring(1));
    StringBuffer sb=new StringBuffer();
    Pattern pattern=Pattern.compile("[A-Z]([a-z\\d]+)?");
    Matcher matcher=pattern.matcher(fieldName);
    while(matcher.find()){
        String word=matcher.group();
        sb.append(word.toUpperCase());
        sb.append(matcher.end() == fieldName.length() ? "" : "_");
    }
    return sb.toString();
}
 
开发者ID:myliang,项目名称:fish-admin,代码行数:16,代码来源:SqlQuery.java

示例2: getContentNext

import java.util.regex.Matcher; //导入方法依赖的package包/类
@Override
public String getContentNext(String baseUrl, String currentUrl, byte[] result) throws UnsupportedEncodingException {
    Document document = Jsoup.parse(new String(result, "gb2312"));
    Elements elements = document.select("div.pagelist a:contains(下一页)");
    if (elements.size() > 0) {
        Pattern pattern = Pattern.compile("http.*/");
        Matcher matcher = pattern.matcher(currentUrl);
        if (matcher.find()) {
            return matcher.group() + elements.get(0).attr("href");
        }
    }
    return "";
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:14,代码来源:Nanrentu.java

示例3: addSmiles

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * replace existing spannable with smiles
 * @param context
 * @param spannable
 * @return
 */
public static boolean addSmiles(Context context, Spannable spannable) {
    boolean hasChanges = false;
    for (Entry<Pattern, Object> entry : emoticons.entrySet()) {
        Matcher matcher = entry.getKey().matcher(spannable);
        while (matcher.find()) {
            boolean set = true;
            for (ImageSpan span : spannable.getSpans(matcher.start(),
                    matcher.end(), ImageSpan.class))
                if (spannable.getSpanStart(span) >= matcher.start()
                        && spannable.getSpanEnd(span) <= matcher.end())
                    spannable.removeSpan(span);
                else {
                    set = false;
                    break;
                }
            if (set) {
                hasChanges = true;
                Object value = entry.getValue();
                if(value instanceof String && !((String) value).startsWith("http")){
                    File file = new File((String) value);
                    if(!file.exists() || file.isDirectory()){
                        return false;
                    }
                    spannable.setSpan(new ImageSpan(context, Uri.fromFile(file)),
                            matcher.start(), matcher.end(),
                            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                }else{
                    spannable.setSpan(new ImageSpan(context, (Integer)value),
                            matcher.start(), matcher.end(),
                            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
            }
        }
    }
    
    return hasChanges;
}
 
开发者ID:Vicent9920,项目名称:FanChat,代码行数:44,代码来源:EaseSmileUtils.java

示例4: getScalePrecision

import java.util.regex.Matcher; //导入方法依赖的package包/类
private String getScalePrecision(String typeWithScale, int index) {

        String pattern = "decimal\\((\\d+),(\\d+)\\)";
        Pattern r = Pattern.compile(pattern);

        Matcher m = r.matcher(typeWithScale);
        if (m.find()) {
            return m.group(index);
        } else {
            return "-999";
        }
    }
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:13,代码来源:HiveMetadataStrategy.java

示例5: pregMatch

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static String pregMatch(String content, String pattern, int index) {

        String match = "";
        Matcher matcher = Pattern.compile(pattern).matcher(content);

        while (matcher.find()) {
            match = matcher.group(index);
            break;
        }

        return TextCrawler.extendedTrim(match);
    }
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:13,代码来源:Regex.java

示例6: whenWithInferredParams

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Convenience fluent builder for constructing a prime with a query, where the parameters are
 * inferred by the query
 *
 * @param query The query string to match against.
 * @return builder for this prime.
 */
private static PrimeBuilder whenWithInferredParams(String query) {
  long posParamCount = query.chars().filter(num -> num == '?').count();

  // Do basic param population for positional types
  HashMap<String, String> paramTypes = new HashMap<>();
  HashMap<String, Object> params = new HashMap<>();
  if (posParamCount > 0) {
    for (int i = 0; i < posParamCount; i++) {
      params.put(Integer.toString(i), "*");
      paramTypes.put(Integer.toString(i), "varchar");
    }
  }
  // Do basic param population for named types
  else {
    List<String> allMatches = new ArrayList<>();
    Pattern p = Pattern.compile("([\\w']+)\\s=\\s:[\\w]+");
    Matcher m = p.matcher(query);
    while (m.find()) {
      allMatches.add(m.group(1));
    }
    for (String match : allMatches) {
      params.put(match, "*");
      paramTypes.put(match, "varchar");
    }
  }
  return when(
      new com.datastax.oss.simulacron.common.request.Query(
          query, Collections.emptyList(), params, paramTypes));
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:37,代码来源:BoundNode.java

示例7: parseIP

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * @return IP Address as a string
 */
public static String parseIP(InetSocketAddress add) {
    Matcher matcher = IP_PATTERN.matcher(add.toString());
    if (matcher.find()) {
        return matcher.group();
    }
    return "";
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:11,代码来源:PunishmentManager.java

示例8: parse

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static String parse(List<List<ChartCharacter>> lines) {
    boolean footnotesFound = false;
    List<ChartCharacter> footnotes = new ArrayList<>();
    for (List<ChartCharacter> line : lines) {
        String text = Chart.convertToText(line);

        Matcher matcher = COPYRIGHT_PATTERN.matcher(text);
        if (matcher.find()) {
            footnotesFound = false;
        }

        matcher = HANDLE.matcher(text);
        if (matcher.find()) {
            footnotesFound = false;
        }

        if (footnotesFound) {
            footnotes.addAll(line);
        }

        matcher = FOOTNOTES.matcher(text);
        if (matcher.find()) {
            footnotesFound = true;
        }
    }

    String notes = Chart.convertToText(footnotes);
    notes = notes.replaceAll("\nDenotes a Keeneland Sales Graduate", "")
            .replaceAll("\n", " ")
            .replaceAll("\\|", " ");

    return notes;
}
 
开发者ID:robinhowlett,项目名称:chart-parser,代码行数:34,代码来源:Footnotes.java

示例9: lexVerbatimData

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Implementation of the "verbatim" tag
 *
 * @throws ParserException
 */
private void lexVerbatimData(Matcher verbatimStartMatcher) throws ParserException {

    // move cursor past the opening verbatim tag
    source.advance(verbatimStartMatcher.end());

    // look for the "endverbatim" tag and storing everything between
    // now and then into a TEXT node
    Matcher verbatimEndMatcher = this.syntax.getRegexVerbatimEnd().matcher(source);

    // check for EOF
    if (!verbatimEndMatcher.find()) {
        throw new ParserException(null, "Unclosed verbatim tag.", source.getLineNumber(), source.getFilename());
    }
    String verbatimText = source.substring(verbatimEndMatcher.start());

    // check if the verbatim start tag has a trailing whitespace trim
    if (verbatimStartMatcher.group(0) != null) {
        verbatimText = StringUtils.ltrim(verbatimText);
    }

    // check if the verbatim end tag had a leading whitespace trim
    if (verbatimEndMatcher.group(1) != null) {
        verbatimText = StringUtils.rtrim(verbatimText);
    }

    // check if the verbatim end tag had a trailing whitespace trim
    if (verbatimEndMatcher.group(2) != null) {
        trimLeadingWhitespaceFromNextData = true;
    }

    // move cursor past the verbatim text and end delimiter
    source.advance(verbatimEndMatcher.end());

    pushToken(Type.TEXT, verbatimText);
}
 
开发者ID:flapdoodle-oss,项目名称:de.flapdoodle.solid,代码行数:41,代码来源:LexerImpl.java

示例10: stdoutShouldMatch

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Verify that the stdout contents of output buffer matches the
 * pattern
 *
 * @param pattern
 * @throws RuntimeException If the pattern was not found
 */
public void stdoutShouldMatch(String pattern) {
    Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stdout);
    if (!matcher.find()) {
        throw new RuntimeException("'" + pattern
                + "' missing from stdout: [" + stdout + "]\n");
    }
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:15,代码来源:OutputAnalyzer.java

示例11: underlineToCamelhump

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * 将下划线风格替换为驼峰风格
 */
public static String underlineToCamelhump(String str) {
    Matcher matcher = Pattern.compile("_[a-z]").matcher(str);
    StringBuilder builder = new StringBuilder(str);
    for (int i = 0; matcher.find(); i++) {
        builder.replace(matcher.start() - i, matcher.end() - i, matcher.group().substring(1).toUpperCase());
    }
    if (Character.isUpperCase(builder.charAt(0))) {
        builder.replace(0, 1, String.valueOf(Character.toLowerCase(builder.charAt(0))));
    }
    return builder.toString();
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:15,代码来源:StringUtil.java

示例12: testMultiRequestHeaders

import java.util.regex.Matcher; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
public void testMultiRequestHeaders() throws Exception {
    TestBidirectionalStreamCallback callback = new TestBidirectionalStreamCallback();
    String headerName = "header-name";
    String headerValue1 = "header-value1";
    String headerValue2 = "header-value2";
    BidirectionalStream.Builder builder =
            new BidirectionalStream.Builder(Http2TestServer.getEchoAllHeadersUrl(), callback,
                    callback.getExecutor(), mTestFramework.mCronetEngine);
    builder.addHeader(headerName, headerValue1);
    builder.addHeader(headerName, headerValue2);
    builder.setHttpMethod("GET");
    builder.build().start();
    callback.blockForDone();
    assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
    String headers = callback.mResponseAsString;
    Pattern pattern = Pattern.compile(headerName + ":\\s(.*)\\r\\n");
    Matcher matcher = pattern.matcher(headers);
    List<String> actualValues = new ArrayList<String>();
    while (matcher.find()) {
        actualValues.add(matcher.group(1));
    }
    assertEquals(1, actualValues.size());
    assertEquals("header-value2", actualValues.get(0));
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:28,代码来源:BidirectionalStreamTest.java

示例13: parseAudios

import java.util.regex.Matcher; //导入方法依赖的package包/类
private static AbsLink parseAudios(String string) {
    Matcher matcher = PATTERN_AUDIOS.matcher(string);
    if (!matcher.find()) {
        return null;
    }

    return new AudiosLink(parseInt(matcher.group(1)));
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:9,代码来源:VkLinkParser.java

示例14: findResource

import java.util.regex.Matcher; //导入方法依赖的package包/类
private static int findResource(String val, String units)
  throws AllocationConfigurationException {
  Pattern pattern = Pattern.compile("(\\d+)\\s*" + units);
  Matcher matcher = pattern.matcher(val);
  if (!matcher.find() && !units.equals("gcores")) {
    throw new AllocationConfigurationException("Missing resource: " + units);
  } else {
    return matcher.find(0) ? Integer.parseInt(matcher.group(1)) : 0;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:FairSchedulerConfiguration.java

示例15: parseRaceDistance

import java.util.regex.Matcher; //导入方法依赖的package包/类
static RaceDistance parseRaceDistance(String distanceDescription) throws ChartParserException {
    String lcDistanceDescription = distanceDescription.toLowerCase();
    Matcher milesOnlyMatcher = MILES_ONLY_PATTERN.matcher(lcDistanceDescription);
    if (milesOnlyMatcher.find()) {
        return forMiles(distanceDescription, milesOnlyMatcher);
    }
    Matcher furlongsOnlyMatcher = FURLONGS_ONLY_PATTERN.matcher(lcDistanceDescription);
    if (furlongsOnlyMatcher.find()) {
        return forFurlongs(distanceDescription, furlongsOnlyMatcher);
    }
    Matcher yardsOnlyMatcher = YARDS_ONLY_PATTERN.matcher(lcDistanceDescription);
    if (yardsOnlyMatcher.find()) {
        return forYards(distanceDescription, yardsOnlyMatcher);
    }
    Matcher milesAndYardsMatcher = MILES_YARDS_PATTERN.matcher(lcDistanceDescription);
    if (milesAndYardsMatcher.find()) {
        return forMilesAndYards(distanceDescription, milesAndYardsMatcher);
    }
    Matcher furlongsAndYardsMatcher = FURLONGS_YARDS_PATTERN.matcher(lcDistanceDescription);
    if (furlongsAndYardsMatcher.find()) {
        return forFurlongsAndYards(distanceDescription, furlongsAndYardsMatcher);
    }
    // sometimes the "Yards" part is missing
    Matcher missingYardsMatcher = MISSING_YARDS_PATTERN.matcher(lcDistanceDescription);
    if (missingYardsMatcher.find()) {
        return forYards(distanceDescription, missingYardsMatcher);
    }

    throw new ChartParserException(String.format("Unable to parse race distance from text: " +
            "%s", distanceDescription));
}
 
开发者ID:robinhowlett,项目名称:chart-parser,代码行数:32,代码来源:DistanceSurfaceTrackRecord.java


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