當前位置: 首頁>>代碼示例>>Java>>正文


Java Pattern.CASE_INSENSITIVE屬性代碼示例

本文整理匯總了Java中java.util.regex.Pattern.CASE_INSENSITIVE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Pattern.CASE_INSENSITIVE屬性的具體用法?Java Pattern.CASE_INSENSITIVE怎麽用?Java Pattern.CASE_INSENSITIVE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.util.regex.Pattern的用法示例。


在下文中一共展示了Pattern.CASE_INSENSITIVE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findMatches

private List<InputNode> findMatches(String name, String value, InputGraph inputGraph, SearchResponse response) {
    try {
        RegexpPropertyMatcher matcher = new RegexpPropertyMatcher(name, value, Pattern.CASE_INSENSITIVE);
        Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<>(inputGraph.getNodes());
        List<InputNode> matches = selector.selectMultiple(matcher);
        return matches.size() == 0 ? null : matches;
    } catch (Exception e) {
        final String msg = e.getMessage();
        response.addResult(new Runnable() {
            @Override
            public void run() {
                Message desc = new NotifyDescriptor.Message("An exception occurred during the search, "
                        + "perhaps due to a malformed query string:\n" + msg,
                        NotifyDescriptor.WARNING_MESSAGE);
                DialogDisplayer.getDefault().notify(desc);
            }
        },
                "(Error during search)"
        );
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:NodeQuickSearch.java

示例2: setText

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,代碼行數:18,代碼來源:SummaryTextFilter.java

示例3: updatePattern

void updatePattern() {
    reset();
    String p = bar.getPattern();
    if (!bar.getRegularExpression()) {
        p = Pattern.quote(p);
        if (bar.getWholeWords()) {
            p="\\b"+p+"\\b"; // NOI18N
        }
    }
    int flags = Pattern.MULTILINE;
    if (!bar.getMatchCase()) {
        flags |= Pattern.CASE_INSENSITIVE;
    }
    try {
        pattern = Pattern.compile(p, flags);
    } catch (PatternSyntaxException psex) {
        String message = NbBundle.getMessage(FindSupport.class, "FindBar.invalidExpression"); // NOI18N
        StatusDisplayer.getDefault().setStatusText(message, StatusDisplayer.IMPORTANCE_FIND_OR_REPLACE);
    }
    findNext();
    if (bar.getHighlightResults()) {
        highlight(tc, false);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:FindSupport.java

示例4: compile

@Override
public Pattern compile(String label)
{
    int reFlags = 0;
    if ((m_flags & SQLPatternFactory.CASE_SENSITIVE) == 0) {
        reFlags |= Pattern.CASE_INSENSITIVE;
    }
    if ((m_flags & SQLPatternFactory.IGNORE_NEW_LINE) == 0) {
        reFlags |= Pattern.DOTALL;
    }
    if ((m_flags & SQLPatternFactory.SINGLE_LINE) == 0) {
        reFlags |= Pattern.MULTILINE;
    }
    String regex = generateExpression(0);
    COMPILER_LOG.debug(String.format("PATTERN: %s: %s", label, regex));
    return Pattern.compile(regex, reFlags);
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:17,代碼來源:SQLPatternPartElement.java

示例5: patternToJoniFlags

private int patternToJoniFlags(int flags) {
  int newFlags = 0;
  if ((flags & Pattern.CASE_INSENSITIVE) != 0) {
    newFlags |= Option.IGNORECASE;
  }
  if ((flags & Pattern.DOTALL) != 0) {
    // This does NOT mean Pattern.MULTILINE
    newFlags |= Option.MULTILINE;
  }
  if ((flags & Pattern.MULTILINE) != 0) {
    // This is what Java 8's Nashorn engine does when using joni and
    // translating Pattern's MULTILINE flag
    newFlags &= ~Option.SINGLELINE;
    newFlags |= Option.NEGATE_SINGLELINE;
  }
  return newFlags;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:17,代碼來源:RegexStringComparator.java

示例6: flagsToString

public static String flagsToString(int flags) {
    StringBuilder sb = new StringBuilder();
    if ((flags & Pattern.CASE_INSENSITIVE) != 0) {
        sb.append("CASE_INSENSITIVE|");
    }
    if ((flags & Pattern.MULTILINE) != 0) {
        sb.append("MULTILINE|");
    }
    if ((flags & Pattern.DOTALL) != 0) {
        sb.append("DOTALL|");
    }
    if ((flags & Pattern.UNICODE_CASE) != 0) {
        sb.append("UNICODE_CASE|");
    }
    if ((flags & Pattern.CANON_EQ) != 0) {
        sb.append("CANON_EQ|");
    }
    if ((flags & Pattern.UNIX_LINES) != 0) {
        sb.append("UNIX_LINES|");
    }
    if ((flags & Pattern.LITERAL) != 0) {
        sb.append("LITERAL|");
    }
    if ((flags & Pattern.COMMENTS) != 0) {
        sb.append("COMMENTS|");
    }
    if ((flags & UNICODE_CHARACTER_CLASS) != 0) {
        sb.append("UNICODE_CHAR_CLASS|");
    }
    return sb.toString();
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:31,代碼來源:Regex.java

示例7: AddRule

/**
 * @param regexp
 * @param output
 */
public void AddRule(String regexp, String output) {
	int nflags = 0 ;
	if (this.caseInsensitive)
	{
		nflags = Pattern.CASE_INSENSITIVE ;
	}
	RegExpRule rule = new RegExpRule() ;
	rule.pattern = Pattern.compile(regexp, nflags) ;
	rule.export = output ;
	lstRules.add(rule) ;
}
 
開發者ID:costea7,項目名稱:ChronoBike,代碼行數:15,代碼來源:RegExpProcessor.java

示例8: flagForChar

private int flagForChar(char c) {
    switch (c) {
        case 'c': return Pattern.CANON_EQ;
        case 'i': return Pattern.CASE_INSENSITIVE;
        case 'l': return Pattern.LITERAL;
        case 'm': return Pattern.MULTILINE;
        case 's': return Pattern.DOTALL;
        case 'U': return Pattern.UNICODE_CHARACTER_CLASS;
        case 'u': return Pattern.UNICODE_CASE;
        case 'x': return Pattern.COMMENTS;
        default:
            throw new IllegalArgumentException("Unknown flag [" + c + "]");
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:14,代碼來源:ERegex.java

示例9: Finder

/**
 * Constructor for Finder.
 */
public Finder(
    HTMLEditor theEditor,
    String find,
    boolean wholeWord,
    boolean matchCase,
    boolean regexp,
    String replace) {
    super();
    editor = theEditor;
    dispText = find;
    int flags = Pattern.DOTALL;
    if (!matchCase)
        flags = flags + Pattern.CASE_INSENSITIVE + Pattern.UNICODE_CASE;
    _find = find;
    if (!regexp)
        _find = "\\Q" + _find + "\\E";
    if (wholeWord)
        _find = "[\\s\\p{Punct}]" + _find + "[\\s\\p{Punct}]";
    try {
        pattern = Pattern.compile(_find, flags);
    }
    catch (Exception ex) {
        ex.printStackTrace();
        pattern = null;
    }
    _replace = replace;
}
 
開發者ID:ser316asu,項目名稱:SER316-Munich,代碼行數:30,代碼來源:Finder.java

示例10: flagsFromString

public static int flagsFromString(String flags) {
    int pFlags = 0;
    for (String s : Strings.delimitedListToStringArray(flags, "|")) {
        if (s.isEmpty()) {
            continue;
        }
        s = s.toUpperCase(Locale.ROOT);
        if ("CASE_INSENSITIVE".equals(s)) {
            pFlags |= Pattern.CASE_INSENSITIVE;
        } else if ("MULTILINE".equals(s)) {
            pFlags |= Pattern.MULTILINE;
        } else if ("DOTALL".equals(s)) {
            pFlags |= Pattern.DOTALL;
        } else if ("UNICODE_CASE".equals(s)) {
            pFlags |= Pattern.UNICODE_CASE;
        } else if ("CANON_EQ".equals(s)) {
            pFlags |= Pattern.CANON_EQ;
        } else if ("UNIX_LINES".equals(s)) {
            pFlags |= Pattern.UNIX_LINES;
        } else if ("LITERAL".equals(s)) {
            pFlags |= Pattern.LITERAL;
        } else if ("COMMENTS".equals(s)) {
            pFlags |= Pattern.COMMENTS;
        } else if (("UNICODE_CHAR_CLASS".equals(s)) || ("UNICODE_CHARACTER_CLASS".equals(s))) {
            pFlags |= UNICODE_CHARACTER_CLASS;
        } else {
            throw new IllegalArgumentException("Unknown regex flag [" + s + "]");
        }
    }
    return pFlags;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:31,代碼來源:Regex.java

示例11: RegexFileFilter

/**
 * Construct a new regular expression filter with the specified flags case sensitivity.
 *
 * @param pattern regular string expression to match
 * @param caseSensitivity  how to handle case sensitivity, null means case-sensitive
 * @throws IllegalArgumentException if the pattern is null
 */
public RegexFileFilter(String pattern, IOCase caseSensitivity) {
    if (pattern == null) {
        throw new IllegalArgumentException("Pattern is missing");
    }
    int flags = 0;
    if (caseSensitivity != null && !caseSensitivity.isCaseSensitive()) {
        flags = Pattern.CASE_INSENSITIVE;
    }
    this.pattern = Pattern.compile(pattern, flags);
}
 
開發者ID:fesch,項目名稱:Moenagade,代碼行數:17,代碼來源:RegexFileFilter.java

示例12: parseFlags

public static int parseFlags(@Nullable BytesRef flagsString) {
    int flags = 0;
    if (flagsString == null) {
        return flags;
    }
    for (char flag : flagsString.utf8ToString().toCharArray()) {
        switch (flag) {
            case 'i':
                flags = flags | Pattern.CASE_INSENSITIVE;
                break;
            case 'u':
                flags = flags | Pattern.UNICODE_CASE;
                break;
            case 'U':
                flags = flags | Pattern.UNICODE_CHARACTER_CLASS;
                break;
            case 's':
                flags = flags | Pattern.DOTALL;
                break;
            case 'm':
                flags = flags | Pattern.MULTILINE;
                break;
            case 'x':
                flags = flags | Pattern.COMMENTS;
                break;
            case 'd':
                flags = flags | Pattern.UNIX_LINES;
                break;
            default:
                break;
        }
    }

    return flags;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:35,代碼來源:RegexMatcher.java

示例13: parse

public void parse(Map<String, RewriteMap> maps) {
    // Parse the substitution
    if (!"-".equals(substitutionString)) {
        substitution = new Substitution();
        substitution.setSub(substitutionString);
        substitution.parse(maps);
    }
    // Parse the pattern
    int flags = 0;
    if (isNocase()) {
        flags |= Pattern.CASE_INSENSITIVE;
    }
    Pattern.compile(patternString, flags);
    // Parse conditions
    for (int i = 0; i < conditions.length; i++) {
        conditions[i].parse(maps);
    }
    // Parse flag which have substitution values
    if (isEnv()) {
        for (int i = 0; i < envValue.size(); i++) {
            Substitution newEnvSubstitution = new Substitution();
            newEnvSubstitution.setSub(envValue.get(i));
            newEnvSubstitution.parse(maps);
            envSubstitution.add(newEnvSubstitution);
            envResult.add(new ThreadLocal<String>());
        }
    }
    if (isCookie()) {
        cookieSubstitution = new Substitution();
        cookieSubstitution.setSub(cookieValue);
        cookieSubstitution.parse(maps);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:RewriteRule.java

示例14: PatternSearch

PatternSearch(final String patternText) {
	super(patternText, true, true, Pattern.CASE_INSENSITIVE
			| Pattern.DOTALL);
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:4,代碼來源:MessageRevFilter.java

示例15: PatternSearch

PatternSearch(final String patternText) {
	super(patternText, true, true, Pattern.CASE_INSENSITIVE);
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:3,代碼來源:CommitterRevFilter.java


注:本文中的java.util.regex.Pattern.CASE_INSENSITIVE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。