Example usage for java.util.regex Matcher find

List of usage examples for java.util.regex Matcher find

Introduction

In this page you can find the example usage for java.util.regex Matcher find.

Prototype

public boolean find() 

Source Link

Document

Attempts to find the next subsequence of the input sequence that matches the pattern.

Usage

From source file:Main.java

private static String makeEmailHerf(String content) {
    if (content.trim().length() == 0) {
        return content;
    }/*from   w  ww.j  ava  2s.c  om*/
    StringBuffer emailStringBuffer = new StringBuffer();

    Matcher matcherEmail = patternEmail.matcher(content);
    while (matcherEmail.find()) {

        String email = matcherEmail.group();
        //            System.out.println("email:" + email);
        String emailToHref = "<a href=\"" + MailTo.MAILTO_SCHEME + email + "\">" + email + "</a>";
        matcherEmail.appendReplacement(emailStringBuffer, emailToHref);

    }
    matcherEmail.appendTail(emailStringBuffer);
    return emailStringBuffer.toString();
}

From source file:Main.java

private static String makeTelNoHerf(String telContent) {
    if (telContent.trim().length() == 0) {
        return telContent;
    }//w ww  .j a  v a2 s  .  c  o m
    StringBuffer telNoStringBuffer = new StringBuffer();

    Matcher matcherTelNo = patternTelNo.matcher(telContent);
    while (matcherTelNo.find()) {

        String telNo = matcherTelNo.group();
        String telNoToHerf = "<a href=\"" + ProtocolKey_ACTION_DIAL + telNo + "\">" + telNo + "</a>";
        matcherTelNo.appendReplacement(telNoStringBuffer, telNoToHerf);

    }
    matcherTelNo.appendTail(telNoStringBuffer);
    return telNoStringBuffer.toString();
}

From source file:com.art4ul.jcoon.util.HttpRequestUtil.java

public static void addKeyValueParams(Context context, String[] stringArray, AddingStatagy addingStatagy) {
    if (stringArray != null) {
        Pattern pattern = Pattern.compile(KEY_VALUE_REGEX_PATTERN);
        for (String str : stringArray) {
            Matcher matcher = pattern.matcher(str);
            while (matcher.find()) {
                if (matcher.groupCount() == 2) {
                    String headerName = matcher.group(1);
                    String headerValue = matcher.group(2);
                    addingStatagy.add(headerName.trim(), headerValue.trim());
                    //context.getHttpHeaders().add(headerName.trim(), headerValue.trim());
                }/* w w w  . j av  a2  s. c om*/
            }
        }
    }
}

From source file:fi.otavanopisto.changelogger.Changelogger.java

private static List<Integer> getIssueNumbers(String description) {
    List<Integer> issues = new ArrayList<>();
    Matcher matcher = ISSUE_REGEX.matcher(description);
    while (matcher.find()) {
        issues.add(Integer.parseInt(matcher.group()));
    }/*from  w ww .  j a  v a 2s. c  om*/
    return issues;
}

From source file:musiccrawler.common.HtmlToolFix.java

public static String searchStreamLink(String script) {
    if (StringUtils.isNoneBlank(script)) {
        Pattern pattern = Pattern.compile(Constant.STREAM_LINK_PATTERN);
        Matcher matcher = pattern.matcher(script);
        if (matcher.find()) {
            return matcher.group(1).trim();
        }/*from  w w  w .  j  a  v a 2 s . co  m*/
    }
    return Constant.EMPTY;
}

From source file:Main.java

/** substitutes the linearDistributions according to the substitution list */
public static String substitute(String currentQIESL, HashMap<Integer, String> substitutionList) {

    StringBuffer result = new StringBuffer();

    int i = 0;/*from  www .j a  va 2s  .  c  o  m*/
    Matcher m = LINEAR_DISTRIUBTIONS.matcher(currentQIESL);
    while (m.find()) {
        if (substitutionList.containsKey(i)) {
            m.appendReplacement(result, substitutionList.get(i));
        }
        i++;
    }
    m.appendTail(result);

    return result.toString();

}

From source file:net.longfalcon.newsj.util.ParseUtil.java

public static String parseImdb(String nfoText) {
    Matcher matcher = _imdbPattern.matcher(nfoText);
    if (matcher.find()) {
        try {//from   ww  w.j  av  a 2 s .c  o  m
            String imdbString = matcher.group(2);
            return imdbString.trim();
        } catch (Exception e) {
            _log.debug(e);
        }
    }
    return null;
}

From source file:net.longfalcon.newsj.util.ParseUtil.java

public static String parseRageId(String nfoText) {
    Matcher matcher = _ragePattern.matcher(nfoText);
    if (matcher.find()) {
        try {/* ww w  . j a  v a 2  s  . c  o  m*/
            String rageIdString = matcher.group(1);
            return rageIdString.trim();
        } catch (Exception e) {
            _log.debug(e);
        }
    }
    return null;
}

From source file:Main.java

public static String getVlaueFromAnnotation(Annotation annotation, String annName) {
    if (cache == null) {
        cache = new LruCache(500);
    }//from w  ww.java2  s .c  o  m
    String annotationString = annotation.toString();
    String cacheKey = "getVlaueByColumnAnnotation:" + annotationString.hashCode() + "," + annName;
    String ret = (String) cache.get(cacheKey);
    if (ret == null || "".equals(ret)) {
        String pattern = annName + "=(.*?),";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(annotation.toString());
        if (m.find()) {
            ret = m.group();
            ret = ret.substring(annName.length() + 1, ret.length() - 1);
        }
        cache.put(cacheKey, ret);
    }
    return ret;
}

From source file:com.android.dialer.lookup.LookupUtils.java

public static String firstRegexResult(String input, String regex, boolean dotall) {
    if (input == null) {
        return null;
    }//from w w  w .j a v a  2 s .  c  o m
    Pattern pattern = Pattern.compile(regex, dotall ? Pattern.DOTALL : 0);
    Matcher m = pattern.matcher(input);
    return m.find() ? m.group(1).trim() : null;
}