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


Java Matcher.appendTail方法代码示例

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


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

示例1: checkTags

import java.util.regex.Matcher; //导入方法依赖的package包/类
private String checkTags(String s) {
    Matcher m = P_TAGS.matcher(s);

    final StringBuffer buf = new StringBuffer();
    while (m.find()) {
        String replaceStr = m.group(1);
        replaceStr = processTag(replaceStr);
        m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr));
    }
    m.appendTail(buf);

    s = buf.toString();

    // these get tallied in processTag
    // (remember to reset before subsequent calls to filter method)
    for (String key : vTagCounts.keySet()) {
        for (int ii = 0; ii < vTagCounts.get(key); ii++) {
            s += "</" + key + ">";
        }
    }

    return s;
}
 
开发者ID:zhaoqicheng,项目名称:renren-fast,代码行数:24,代码来源:HTMLFilter.java

示例2: map

import java.util.regex.Matcher; //导入方法依赖的package包/类
@Override
public String map(String entry) {
    for (Map.Entry<Pattern, String> replacement : replacements.entrySet()) {
        Matcher matcher = replacement.getKey().matcher(entry);
        String value = replacement.getValue();
        StringBuffer sb = new StringBuffer();
        while (matcher.find()) {
            matcher.appendReplacement(sb, value);
        }
        matcher.appendTail(sb);
        if (sb.length() > 0) {
            entry = sb.toString();
        }
    }
    return entry;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:FlameGraphSanitizer.java

示例3: replaceParameter

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * 替换url中参数的值。
 */
public static String replaceParameter(String query, String key, String value) {
    if (query == null || query.length() == 0) {
        return key + "=" + value;
    }
    if (query.indexOf(key + "=") == -1) {
        return query + "&" + key + "=" + value;
    }
    Pattern pattern = REPLACE_PARAMETER_PATTERNS.get(key);
    if (pattern == null) {
        pattern = Pattern.compile(key.replaceAll("([^(_0-9A-Za-z)])", "\\\\$0") + "=[^&]+");
    }
    Matcher matcher = pattern.matcher(query);
    StringBuffer sb = new StringBuffer();
    while (matcher.find()) {
        matcher.appendReplacement(sb, (key + "=" + value).replace("$", "\\$"));
    }
    matcher.appendTail(sb);
    return sb.toString();
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:23,代码来源:ParseUtils.java

示例4: resolveLinks

import java.util.regex.Matcher; //导入方法依赖的package包/类
private String resolveLinks(RichTextElement element) {
    if (element.links == null) {
        return element.getValue();
    }
    Matcher matcher = linkPattern.matcher(element.getValue());
    StringBuffer buffer = new StringBuffer();
    while (matcher.find()) {
        Link link = element.links.get(matcher.group("id"));
        String url = "";
        if (link != null  && contentLinkUrlResolver != null) {
            url = contentLinkUrlResolver.resolveLinkUrl(link);
        } else if (brokenLinkUrlResolver != null){
            url = brokenLinkUrlResolver.resolveBrokenLinkUrl();
        }
        matcher.appendReplacement(buffer, resolveMatch(matcher.group(0), url));
    }
    matcher.appendTail(buffer);
    return buffer.toString();
}
 
开发者ID:Kentico,项目名称:delivery-sdk-java,代码行数:20,代码来源:RichTextElementConverter.java

示例5: readWithReplace

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Reads a string from the given file, replacing instances of $(path) with the contents of the file at that path.
 * Must be cycle-free to terminate.
 * $(path) entries in referenced files are handled recursively,
 * the path always being relative to the referencing file.
 * @param path the path of the root file
 * @return a string where all occurrences of $(...) have been replaced recursively
 * @throws IOException if any one file could not be read
 */
public static String readWithReplace(String path) throws IOException {
    String text = readString(path);
    Matcher m = pattern.matcher(text);
    StringBuffer result = new StringBuffer();
    File file = new File(path).getAbsoluteFile();
    String subPath = "";
    while(m.find()){
        try {
            subPath = file.getParent() + "/" + m.group(1);
            m.appendReplacement(result, readWithReplace(subPath));
        } catch(NullPointerException e){
            e.printStackTrace();
            Log.log(Log.Level.ERROR, "Could not insert file " + subPath + " into " + path);
        }
    }
    m.appendTail(result);
    return result.toString();
}
 
开发者ID:agentcontest,项目名称:massim,代码行数:28,代码来源:IOUtil.java

示例6: replaceParameter

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * 替换url中参数的值。
 */
public static String replaceParameter(String query, String key, String value) {
    if (query == null || query.length() == 0) {
        return key + "=" + value;
    }
    if (query.indexOf(key + "=") == -1) {
    	return query + "&" + key + "=" + value;
    }
    Pattern pattern = REPLACE_PARAMETER_PATTERNS.get(key);
    if (pattern == null) {
    	pattern = Pattern.compile(key.replaceAll("([^(_0-9A-Za-z)])", "\\\\$0") + "=[^&]+");
    }
    Matcher matcher = pattern.matcher(query);
    StringBuffer sb = new StringBuffer();
    while (matcher.find()) {
        matcher.appendReplacement(sb, (key + "=" + value).replace("$", "\\$"));
    }
    matcher.appendTail(sb);
    return sb.toString();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:23,代码来源:ParseUtils.java

示例7: interpolate

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * 执行interpolation(变量插入)。
 * 
 * @param expression 含有变量的表达式字符串。表达式中的变量名也可以用<code>{}</code>括起来。
 * @param params 变量集。变量名可以包含<code>.</code>、<code>_</code>字符。
 * @return 完成interpolation后的字符串。 如:<code><pre>xxx${name}zzz -> xxxjerryzzz</pre></code>(其中变量name="jerry")
 * @throws IllegalStateException 表达式字符串中使用到的变量 在变量集中没有
 */
// FIMXE 抛出IllegalStateException异常,是否合适?!
public static String interpolate(String expression, Map<String, String> params) {
    if (expression == null || expression.length() == 0) {
        throw new IllegalArgumentException("glob pattern is empty!");
    }
    if (expression.indexOf('$') < 0) {
        return expression;
    }
    Matcher matcher = VARIABLE_PATTERN.matcher(expression);
    StringBuffer sb = new StringBuffer();
    while (matcher.find()) { // 逐个匹配
        String key = matcher.group(1);
        String value = params == null ? null: params.get(key);
        if (value == null) {
        	value = "";
        }
        matcher.appendReplacement(sb, value);
    }
    matcher.appendTail(sb);
    return sb.toString();
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:30,代码来源:ParseUtils.java

示例8: escapeString

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * Escape string suitable for display in a tree
 * @param string the raw string
 * @return the escaped string
 */
public static String escapeString(final String string) {
	final Matcher match = CTRL_CHR.matcher(string);
	final StringBuffer sb = new StringBuffer();
	while (match.find()) {
		int cp = match.group().codePointAt(0);
		match.appendReplacement(sb, String.format("\\\\%02X", cp));
	}
	match.appendTail(sb);
	return sb.toString();
}
 
开发者ID:kiwiwings,项目名称:poi-visualizer,代码行数:16,代码来源:TreeModelUtils.java

示例9: format

import java.util.regex.Matcher; //导入方法依赖的package包/类
@Override
public String format(String str, Object... args) throws IllegalFormatException
{
    final int RULE_BEGIN_INDEX = 1;

    // Apply rule pattern to input string to
    // find inline matches
    Matcher matcher = RULE_PATTERN.matcher(str);
    // Formatted string buffer
    StringBuffer formatBuffer = new StringBuffer();

    // Find all inline rules within the input string
    for (int i = 0; matcher.find() && i < args.length; ++i)
    {
        // Remove $ from the matched rule string
        String rule = matcher.group().substring(RULE_BEGIN_INDEX);
        Object arg = args[i];

        // Format the specified rule according to given specifications
        String replacement = FORMAT_SPEC.applyRule(rule, arg);
        // Ensure replacement string is converted into literal
        // string (ensure \ and $ characters are treated correctly)
        matcher.appendReplacement(formatBuffer, Matcher.quoteReplacement(replacement));
    }

    matcher.appendTail(formatBuffer);
    return formatBuffer.toString();
}
 
开发者ID:mochalog,项目名称:mochalog,代码行数:29,代码来源:AbstractFormatter.java

示例10: removeQuotes

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static String removeQuotes(String input) {
    Pattern compile = Pattern.compile("\"([A-Z_0-9]+)\"", Pattern.DOTALL);

    StringBuffer sb = new StringBuffer(input.length());

    Matcher matcher = compile.matcher(input);
    while (matcher.find()) {
        matcher.appendReplacement(sb, matcher.group(1));
    }
    matcher.appendTail(sb);

    return sb.toString();
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:14,代码来源:AbstractDdlReveng.java

示例11: escapeComments

import java.util.regex.Matcher; //导入方法依赖的package包/类
private String escapeComments(final String s) {
    final Matcher m = P_COMMENTS.matcher(s);
    final StringBuffer buf = new StringBuffer();
    if (m.find()) {
        final String match = m.group(1); //(.*?)
        m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->"));
    }
    m.appendTail(buf);

    return buf.toString();
}
 
开发者ID:lemon-china,项目名称:lemon-framework,代码行数:12,代码来源:HTMLFilter.java

示例12: getEmotion

import java.util.regex.Matcher; //导入方法依赖的package包/类
private String getEmotion(String var1) {
    Pattern var2 = Pattern.compile("\\[/u([0-9A-Fa-f]+)\\]");
    Matcher var3 = var2.matcher(var1);
    StringBuffer var4 = new StringBuffer();

    while (var3.find()) {
        int var5 = Integer.parseInt(var3.group(1), 16);
        var3.appendReplacement(var4, String.valueOf(Character.toChars(var5)));
    }

    var3.appendTail(var4);
    return var4.toString();
}
 
开发者ID:GitLqr,项目名称:LQRWeChat,代码行数:14,代码来源:DeleteContactMessage.java

示例13: cleanTextForSearchingQuery

import java.util.regex.Matcher; //导入方法依赖的package包/类
@NonNull
public static String cleanTextForSearchingQuery(String s) {

    Matcher matcher = SPACE_REPLACED_PATTERN.matcher(s);
    String space_replaced = matcher.replaceAll(" ");

    Matcher matcher1 = REMOVE_PATTERN.matcher(space_replaced);
    String removed = matcher1.replaceAll("");

    Matcher matcher2 = REMOVE_REPEATED_SPACES.matcher(removed);
    String removed_duplicat_spaces = matcher2.replaceAll(" ");

    Matcher equivlanceMatcher = equvilancePattern.matcher(removed_duplicat_spaces);

    StringBuffer sb = new StringBuffer();
    while (equivlanceMatcher.find()) {
        switch (equivlanceMatcher.group(0)) {
            case DOTLESS_YEH_STR:
                equivlanceMatcher.appendReplacement(sb, YEH_STR);
                break;
            case ALEF_MADDA_str:
            case ALEF_HAMZA_ABOVE_str:
            case ALEF_HAMZA_BELOW_STR:
                equivlanceMatcher.appendReplacement(sb, ALEF_str);
                break;
            case TEH_MARBUTA_STR:
                equivlanceMatcher.appendReplacement(sb, HEH_STR);
        }
    }
    equivlanceMatcher.appendTail(sb);

    return handleTatweela(sb.toString());
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:34,代码来源:ArabicUtilities.java

示例14: humpToLine2

import java.util.regex.Matcher; //导入方法依赖的package包/类
/**
 * 驼峰转下划线,效率比上面高
 * @param str
 * @return
 */
public static String humpToLine2(String str) {
    Matcher matcher = humpPattern.matcher(str);
    StringBuffer sb = new StringBuffer();
    while (matcher.find()) {
        matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
    }
    matcher.appendTail(sb);
    return sb.toString();
}
 
开发者ID:lgpzjp,项目名称:rure,代码行数:15,代码来源:StringUtil.java

示例15: appendTail

import java.util.regex.Matcher; //导入方法依赖的package包/类
public static void appendTail(Matcher matcher, Node node) {
	StringBuffer buffer = new StringBuffer();
	matcher.appendTail(buffer);
	if (buffer.length() != 0)
		node.before(new TextNode(buffer.toString(), node.baseUri()));
	node.remove();
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:8,代码来源:JsoupUtils.java


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