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


Java Pattern.quote方法代码示例

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


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

示例1: extractVersionFrom

import java.util.regex.Pattern; //导入方法依赖的package包/类
public static String extractVersionFrom(String str, Context context) {
    String version = "";

    if (!str.isEmpty()) {
        String delimiter = OTAConfig.getInstance(context).getDelimiter();
        int position = OTAConfig.getInstance(context).getPosition();

        if (delimiter.isEmpty()) {
            version = str;
        } else {
            if (delimiter.equals(".")) {
                delimiter = Pattern.quote(".");
            }
            String[] tokens = str.split(delimiter);
            if (position > -1 && position < tokens.length) {
                version = tokens[position];
            }
        }
    }

    return version;
}
 
开发者ID:DroidThug,项目名称:VulcanOTA,代码行数:23,代码来源:OTAVersion.java

示例2: fromPath

import java.util.regex.Pattern; //导入方法依赖的package包/类
public static NanoRepositoryProject fromPath(String jarPath) {
    String splitRegex = Pattern.quote(System.getProperty("file.separator"));
    String[] sides = jarPath.split(splitRegex + "repositories" + splitRegex);

    String path = sides[sides.length - 1];
    String[] dirs = path.split(splitRegex);

    String repositoryName = dirs[0];
    String versionDir = dirs[dirs.length - 2];
    String artifactId = dirs[dirs.length - 3];

    StringBuilder groupIdBuilder = new StringBuilder(dirs[1]);
    for (int i = 2; i < dirs.length - 3; i++) {
        groupIdBuilder.append(".").append(dirs[i]);
    }
    String groupId = groupIdBuilder.toString();

    return new NanoRepositoryProject(repositoryName, groupId, artifactId, versionDir);
}
 
开发者ID:dzikoysk,项目名称:NanoMaven,代码行数:20,代码来源:NanoRepositoryProject.java

示例3: setText

import java.util.regex.Pattern; //导入方法依赖的package包/类
public void setText(String text, boolean regular, boolean wholeWords, boolean matchCase) {
    if (!regular) {
        text = Pattern.quote(text);
        if (wholeWords) {
            text ="\\b"+ text +"\\b"; // NOI18N
        }
    }
    int flags = 0;
    if (!matchCase) {
        flags |= Pattern.CASE_INSENSITIVE;
    }
    try {
        pattern = Pattern.compile(text, flags);
    } catch (PatternSyntaxException psex) {
        String message = NbBundle.getMessage(SummaryTextFilter.class, "FindInQueryBar.invalidExpression"); // NOI18N
        StatusDisplayer.getDefault().setStatusText(message, StatusDisplayer.IMPORTANCE_FIND_OR_REPLACE);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SummaryTextFilter.java

示例4: createSplitOperation

import java.util.regex.Pattern; //导入方法依赖的package包/类
private List<SubOperation> createSplitOperation(NamedNodeMap node) {
    List<SubOperation> subOperations = new ArrayList<>();
    String splitPattern = Pattern.quote("||");

    String[] splitAmount = node.getNamedItem("samt").getNodeValue().split(splitPattern);
    String[] splitCategoryKey = node.getNamedItem("scat").getNodeValue().split(splitPattern);

    String[] splitMemo = new String[splitAmount.length];
    if (node.getNamedItem("smem") != null) {
        splitMemo = node.getNamedItem("smem").getNodeValue().split(splitPattern);
    }

    for (int i = 0; i < splitAmount.length; i++) {
        subOperations.add(new SubOperation(
                i < splitCategoryKey.length ? Integer.parseInt(splitCategoryKey[i]) : 0,
                Float.parseFloat(splitAmount[i]),
                i < splitMemo.length ? splitMemo[i] : ""
        ));
    }
    return subOperations;
}
 
开发者ID:monsieurh,项目名称:homebank_android,代码行数:22,代码来源:OperationFactory.java

示例5: getCompletionPrefix

import java.util.regex.Pattern; //导入方法依赖的package包/类
private String getCompletionPrefix() {
    if (separators != null) {
        int pos = field.getCaretPosition();
        String currentText = field.getText();
        StringTokenizer tok = new StringTokenizer(currentText, separators, true);
        int count = 0;
        String lastToken = ""; //NOI18N
        while (tok.hasMoreTokens()) {
            String token = tok.nextToken();
            if (count + token.length() >= pos) {
                if (separators.indexOf(token.charAt(0)) != -1) {
                    return ""; //NOI18N
                }
                return Pattern.quote(token.substring(0, pos - count));
            } else {
                count = count + token.length();
                lastToken = token;
            }
        }
        if (lastToken.length() > 0 && separators.indexOf(lastToken.charAt(0)) == -1) {
            return Pattern.quote(lastToken);
        }
        return ""; //NOI18N
    } else {
        return Pattern.quote(field.getText().trim());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:TextValueCompleter.java

示例6: retrieveChangesetErrorResponse

import java.util.regex.Pattern; //导入方法依赖的package包/类
private String retrieveChangesetErrorResponse(int statusCode, String code, String message) {
    return "Content-Type: multipart/mixed; "
            + "boundary=changeset_cLzcDEEVPwvvoxS3yJTFTpRauSK_FAQ6mQtyo0aby93-SDP3lAs2A19a2uBb\n\n"
            + "--changeset_cLzcDEEVPwvvoxS3yJTFTpRauSK_FAQ6mQtyo0aby93-SDP3lAs2A19a2uBb\n"
            + "Content-Type: application/http\n"
            + "Content-Transfer-Encoding: binary\n\n"
            + "HTTP/1.1 " + String.valueOf(statusCode) + " \n"
            + "Content-Type: application/json\n\n"
            + "\\{\"code\":\"" + code + "\",\"message\":\\{\"lang\":\"en\",\"value\":\"" + Pattern.quote(message)
            + ".*\n\n"
            + "--changeset_cLzcDEEVPwvvoxS3yJTFTpRauSK_FAQ6mQtyo0aby93-SDP3lAs2A19a2uBb--\n\n";
}
 
开发者ID:personium,项目名称:personium-core,代码行数:13,代码来源:UserDataBatchLinkTest.java

示例7: PlainLoggerLogic

import java.util.regex.Pattern; //导入方法依赖的package包/类
PlainLoggerLogic(HudsonJob job, String jobName) {
    this.job = job;
    // XXX support Windows build servers (using backslashes)
    String jobNameQ = Pattern.quote(jobName);
    hyperlinkable = Pattern.compile("\\s*(?:\\[.+\\] )?/.+?/(?:jobs/" + jobNameQ + "/workspace|workspace/" + jobNameQ + // NOI18N
            ")/([^:]+):(?:\\[?([0-9]+)[:,](?:([0-9]+)[]:])?)? (?:warning: )?(.+)"); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:PlainLogger.java

示例8: getMessage

import java.util.regex.Pattern; //导入方法依赖的package包/类
protected String getMessage() {
	String message = this.message;
	
	message = Pattern.quote(message); //Turn special characters into literal so they don't get parsed out
	message = message.substring(2, message.length()-3).trim(); //Remove '\Q' and '\E' from beginning/end since we're not using this as a regex
	message = message.replace("\"", "\\\""); //Also, make sure quote marks are properly escaped!
	
	return message;
}
 
开发者ID:privacyint,项目名称:thornsec-core,代码行数:10,代码来源:SimpleUnit.java

示例9: reload

import java.util.regex.Pattern; //导入方法依赖的package包/类
/**
 * Reloads the content from the fileSystem
 */
@Override
public void reload() {
    this.items.clear();
    try {
        final Cipher decipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
        decipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(Base64Coder.decode("NTk50mqoZMw9ZTxcQJlVhA=="), "AES"), new IvParameterSpec("RandomInitVector".getBytes("UTF-8")));
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(new CipherInputStream(JavaPlugin.getPlugin(PetBlocksPlugin.class).getResource("minecraftheads.db"), decipher)))) {
            String s;
            final String splitter = Pattern.quote(",");
            int i = 0;
            while ((s = reader.readLine()) != null) {
                final String[] tags = s.split(splitter);
                if (tags.length == 2 && tags[1].length() % 4 == 0) {
                    i++;
                    try {
                        final String line = Base64Coder.decodeString(tags[1]).replace("{\"textures\":{\"SKIN\":{\"url\":\"", "");
                        final String url = line.substring(0, line.indexOf("\""));
                        final String texture = url.substring(7, url.length());
                        final GUIItemContainer container = new ItemContainer(true, i, GUIPage.MINECRAFTHEADS_COSTUMES, 397, 3, texture, false, tags[0].replace("\"", ""), new String[0]);
                        this.items.add(container);
                    } catch (final Exception ignored) {
                        PetBlocksPlugin.logger().log(Level.WARNING, "Failed parsing minecraftheads.com head.", ignored);
                    }
                }
            }
        }
    } catch (IOException | InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException e) {
        PetBlocksPlugin.logger().log(Level.WARNING, "Failed to read minecraft-heads.com skins.");
    }
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:34,代码来源:MinecraftHeadConfiguration.java

示例10: sanitizeColumnProjectionList

import java.util.regex.Pattern; //导入方法依赖的package包/类
private static String sanitizeColumnProjectionList(String sqlStatement) {
	String[] columnProjectionListPatternElements = { "select distinct ", "[a-z0-9_]+", Pattern.quote(SQL_ASSOCIATION_PATH_SEPARATOR), " as ", ", ", " from " };
	StringBuilder columnProjectionListPattern = new StringBuilder("^");
	columnProjectionListPattern.append(columnProjectionListPatternElements[0]);
	columnProjectionListPattern.append("((");
	columnProjectionListPattern.append(columnProjectionListPatternElements[1]);
	columnProjectionListPattern.append(columnProjectionListPatternElements[2]);
	columnProjectionListPattern.append("(");
	columnProjectionListPattern.append(columnProjectionListPatternElements[1]);
	columnProjectionListPattern.append(")");
	columnProjectionListPattern.append(columnProjectionListPatternElements[3]);
	columnProjectionListPattern.append(columnProjectionListPatternElements[1]);
	columnProjectionListPattern.append("(");
	columnProjectionListPattern.append(columnProjectionListPatternElements[4]);
	columnProjectionListPattern.append(")?)+)");
	columnProjectionListPattern.append(columnProjectionListPatternElements[5]);
	Matcher columnProjectionListMatcher = Pattern.compile(columnProjectionListPattern.toString(), Pattern.CASE_INSENSITIVE).matcher(sqlStatement);
	StringBuilder result = new StringBuilder(columnProjectionListPatternElements[0]);
	if (columnProjectionListMatcher.lookingAt()) {
		String[] columnProjectionList = columnProjectionListMatcher.group(1).split(columnProjectionListPatternElements[4], -1);
		for (int i = 0; i < columnProjectionList.length; i++) {
			String[] columnProjection = columnProjectionList[i].trim().split(columnProjectionListPatternElements[3], 2);
			String columnIdentifier = columnProjection[0].trim();
			String[] columnName = columnIdentifier.split(columnProjectionListPatternElements[2], 2);
			if (i > 0) {
				result.append(columnProjectionListPatternElements[4]);
			}
			result.append(columnIdentifier);
			result.append(columnProjectionListPatternElements[3]);
			result.append(columnName[1].trim());
		}
		result.append(columnProjectionListPatternElements[5]);
		return columnProjectionListMatcher.replaceFirst(java.util.regex.Matcher.quoteReplacement(result.toString()));
	}
	return sqlStatement;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:37,代码来源:QueryUtil.java

示例11: getDefaultFilters

import java.util.regex.Pattern; //导入方法依赖的package包/类
@Override
public List<Filter> getDefaultFilters(SipProfile acc) {
    ArrayList<Filter> filters = new ArrayList<Filter>();
    
    Filter f = new Filter();
    f.account = (int) acc.id;
    f.action = Filter.ACTION_REPLACE;
    f.matchPattern = "^" + Pattern.quote("+") + "(.*)$";
    f.replacePattern = "00$1";
    f.matchType = Filter.MATCHER_STARTS;
    filters.add(f);
    
    return filters;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:15,代码来源:Blicnet.java

示例12: quote

import java.util.regex.Pattern; //导入方法依赖的package包/类
private static String quote(String s, int start, int end) {
    if (start == end) {
        return "";
    }

    return Pattern.quote(s.substring(start, end));
}
 
开发者ID:StefaniniInspiring,项目名称:pugtsdb,代码行数:8,代码来源:GlobPattern.java

示例13: getRegexp

import java.util.regex.Pattern; //导入方法依赖的package包/类
/**
 * Gets regular expression to match methods
 *
 * @return string representation of the regular expression
 */
public String getRegexp() {
    // regexp should have a . as a method separator
    // and / as a package/class separator
    return aClass.getRegexp().replaceAll("\\.", "/")
            .replaceAll("/\\*", ".*")
            + Pattern.quote(Separator.DOT.symbol)
            + aMethod.getRegexp() + aSignature.getRegexp();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:MethodDescriptor.java

示例14: computeTypeNames

import java.util.regex.Pattern; //导入方法依赖的package包/类
@Override
public void computeTypeNames(Context context, Result result) {
    StringBuilder pattern = new StringBuilder();
    boolean sensitive = true;

    String quotedText = Pattern.quote(context.getText());

    switch (context.getSearchType()) {
        case CASE_INSENSITIVE_EXACT_NAME:
            sensitive = false;
        case CAMEL_CASE:
            pattern.append(Queries.createCamelCaseRegExp(context.getText(), null, null, sensitive));
            break;
        case CASE_INSENSITIVE_CAMEL_CASE:
            sensitive = false;
            pattern.append(Queries.createCamelCaseRegExp(context.getText(), null, null, sensitive));
            break;
        case EXACT_NAME:
            pattern.append("^").append(quotedText).append("$"); // NOI18N
            break;
        case CASE_INSENSITIVE_PREFIX:
            sensitive = false;
        case PREFIX:
            pattern.append("^").append(quotedText); // NOI18N
            break;
        case CASE_INSENSITIVE_REGEXP:
            sensitive = false;
        case REGEXP:
            pattern.append(
                    NameMatcherFactory.wildcardsToRegexp(
                        JavaTypeProvider.removeNonJavaChars(context.getText()),
                        false
                    )
            );
            break;
    }
    Pattern searchPattern = Pattern.compile(
            pattern.toString(),
            Pattern.MULTILINE +
                (sensitive ? 0 : Pattern.CASE_INSENSITIVE));

    for (Map.Entry<FileObject, OpenProjectFastIndex.NameIndex> one : fastIndex.copyIndexes().entrySet()) {
        FileObject root = one.getKey();
        Project p = FileOwnerQuery.getOwner(root);

        if (context.getProject() != null && !context.getProject().equals(p)) {
            continue;
        }
        OpenProjectFastIndex.NameIndex fileIndex = one.getValue();

        Matcher m = searchPattern.matcher(fileIndex.files());
        while (m.find()) {
            if (cancel.get()) {
                LOG.fine("Search canceled");
                return;
            }
            if (m.start() == m.end()) {
                continue;
            }
            CharSequence f = fileIndex.getFilename(m.start(), m.end());
            CharSequence pkg = fileIndex.findPath(m.start());
            SimpleDescriptor desc = new SimpleDescriptor(p, root, f, pkg);
            result.addResult(desc);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:67,代码来源:FastTypeProvider.java

示例15: quote

import java.util.regex.Pattern; //导入方法依赖的package包/类
private String quote(String fullPath, int start, int end) {
	if (start == end) {
		return "";
	}
	return Pattern.quote(fullPath.substring(start, end));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:UriTemplate.java


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