获取文字中的敏感词
@param txt 文字
@param matchType 匹配规则&nbsp;1：最小匹配规则，2：最大匹配规则
@return
@version 1.0
977893
public Set<String> findSensitiveWord(String txt , MatchType matchType){
		Set<String> sensitiveWordList = new HashSet<String>();
		for(int i = 0 ; i < txt.length() ; i++){
			int length = checkSensitiveWord(txt, i, matchType);    //判断是否包含敏感字符
			if(length > 0){    //存在,加入list中
				sensitiveWordList.add(txt.substring(i, i+length));
				i = i + length - 1;    //减1的原因，是因为for会自增
			}
		}
		return sensitiveWordList;
	}
176558
private static int matchesAt(CharSequence text, int offsetInText, CharSequence substring) {
        int len = substring.length();
        int textLength = text.length();
        if (textLength + offsetInText > len) {
            return -1;
        }
        int i = 0;
        for (int j = offsetInText; i < len; ++i, ++j) {
            char pc = substring.charAt(i);
            char tc = text.charAt(j);
            if (pc != tc) return -1;
        }
        return i;
    }
639448
@SuppressWarnings("unchecked")
    public static <T> T argThat(Matcher<T> matcher) {
        reportMatcher(matcher);
        return  (T) defaultValue(genericTypeOfMatcher(matcher.getClass()));
    }
626191
static final int match(String text, int pos, int ch) {
        if (pos < 0 || pos >= text.length()) {
            return -1;
        }
        pos = skipBidiMarks(text, pos);
        if (PatternProps.isWhiteSpace(ch)) {
            // Advance over run of white space in input text
            // Must see at least one white space char in input
            int s = pos;
            pos = skipPatternWhiteSpace(text, pos);
            if (pos == s) {
                return -1;
            }
            return pos;
        }
        if (pos >= text.length() || UTF16.charAt(text, pos) != ch) {
            return -1;
        }
        pos = skipBidiMarks(text, pos + UTF16.getCharCount(ch));
        return pos;
    }
1159171
public Token getMatchedToken(final int tokenType) throws RecognitionException {
        Token result = parser.getCurrentToken();
        boolean isIdentifierCompatible = false;
        if (identifierTokenIndex == tokenType && identifierTokenIndex > result.getType()) {
            isIdentifierCompatible = true;
        }
        if (result.getType() == tokenType || isIdentifierCompatible) {
            if (Token.EOF != tokenType && isIdentifierCompatible && result instanceof CommonToken) {
                ((CommonToken) result).setType(identifierTokenIndex);
            }
            parser.getErrorHandler().reportMatch(parser);
            parser.consume();
        } else {
            result = parser.getErrorHandler().recoverInline(parser);
            if (parser.getBuildParseTree() && -1 == result.getTokenIndex()) {
                parser.getContext().addErrorNode(parser.createErrorNode(parser.getContext(), result));
            }
        }
        return result;
    }
494430
public boolean fileMatchesRules(File file) {

        try {
            if(file.exists()) {
                if(includeFilesContainingText.length == 0 && excludeFilesContainingText.length == 0) {
                    return fileMatchesRules(
							getComparableFileName(file));
                } else {
                    return fileMatchesRules(
							getComparableFileName(file),
                            FileSupport.getTextFileFromFS(file));
                }
            }
        } catch (IOException ioe) {
            //at the moment file does not match rules
        }
		return false;
	}
1224727
def matches(self, txt: str) -> bool:
        
        # rval = ref.getText()[1:-1].encode('utf-8').decode('unicode-escape')
        if r'\\u' in self.pattern_re.pattern:
            txt = txt.encode('utf-8').decode('unicode-escape')
        match = self.pattern_re.match(txt)
        return match is not None and match.end() == len(txt)
410214
@Override
    public int matches(Replaceable text,
                       int[] offset,
                       int limit,
                       boolean incremental) {
        int c;
        if (offset[0] < limit &&
            contains(c = text.char32At(offset[0]))) {
            offset[0] += UTF16.getCharCount(c);
            return U_MATCH;
        }
        if (offset[0] > limit && contains(text.char32At(offset[0]))) {
            // Backup offset by 1, unless the preceding character is a
            // surrogate pair -- then backup by 2 (keep offset pointing at
            // the lead surrogate).
            --offset[0];
            if (offset[0] >= 0) {
                offset[0] -= UTF16.getCharCount(text.char32At(offset[0])) - 1;
            }
            return U_MATCH;
        }
        if (incremental && offset[0] == limit) {
            return U_PARTIAL_MATCH;
        }
        return U_MISMATCH;
    }
864681
public static Matcher<MultiResult> sequence(final Matcher<?>... matchers) {
        checkNotEmpty(matchers);
        return new Matcher<MultiResult>() {
            @Override
            public MultiResult matches(String input, boolean isEof) {
                int matchCount = 0;
                Result[] results = new Result[matchers.length];
                Arrays.fill(results, failure(input, false));
                int beginIndex = 0;
                for (int i = 0; i < matchers.length; i++) {
                    Result result = matchers[i].matches(input.substring(beginIndex), isEof);
                    if (result.isSuccessful()) {
                        beginIndex += result.end();
                        results[i] = result;
                        if (++matchCount == matchers.length) {
                            String group = result.group();
                            Result finalResult = new SimpleResult(
                                    true,
                                    input,
                                    input.substring(0, beginIndex - group.length()),
                                    group,
                                    result.canStopMatching());
                            return new MultiResultImpl(finalResult, Arrays.asList(results));
                        }
                    } else {
                        break;
                    }
                }
                final List<Result> resultList = Arrays.asList(results);
                boolean canStopMatching = MultiResultImpl.canStopMatching(resultList);
                return new MultiResultImpl(failure(input, canStopMatching), resultList);
            }

            @Override
            public String toString() {
                return String.format("sequence(%s)", MultiMatcher.matchersToString(matchers));
            }
        };
    }
325020
static final int match(String text, int pos, String str) {
        for (int i = 0; i < str.length() && pos >= 0;) {
            int ch = UTF16.charAt(str, i);
            i += UTF16.getCharCount(ch);
            if (isBidiMark(ch)) {
                continue;
            }
            pos = match(text, pos, ch);
            if (PatternProps.isWhiteSpace(ch)) {
                i = skipPatternWhiteSpace(str, i);
            }
        }
        return pos;
    }
474179
func (p *Parser) MatchType(typ TokenType) *Token {
	if t := p.PeekType(typ); t != nil {
		p.Consume()
		return t
	}
	return nil
}
1257645
func MatchFile(filepath string) (types.Type, error) {
	file, err := os.Open(filepath)
	if err != nil {
		return types.Unknown, err
	}
	defer file.Close()

	return MatchReader(file)
}
134899
private ClassMatcher buildMatcher(String tagText) {
	// check there are at least @match <type> and a parameter
	String[] strings = StringUtil.tokenize(tagText);
	if (strings.length < 2) {
	    System.err.println("Skipping uncomplete @match tag, type missing: " + tagText + " in view " + viewDoc);
	    return null;
	}
	
	try {
	    if (strings[0].equals("class")) {
		return new PatternMatcher(Pattern.compile(strings[1]));
	    } else if (strings[0].equals("context")) {
		return new ContextMatcher(root, Pattern.compile(strings[1]), getGlobalOptions(), 
			false);
	    } else if (strings[0].equals("outgoingContext")) {
		return new ContextMatcher(root, Pattern.compile(strings[1]), getGlobalOptions(), 
			false);
	    } else if (strings[0].equals("interface")) {
		return new InterfaceMatcher(root, Pattern.compile(strings[1]));
	    } else if (strings[0].equals("subclass")) {
		return new SubclassMatcher(root, Pattern.compile(strings[1]));
	    } else {
		System.err.println("Skipping @match tag, unknown match type, in view " + viewDoc);
	    }
	} catch (PatternSyntaxException pse) {
	    System.err.println("Skipping @match tag due to invalid regular expression '" + tagText
		    + "'" + " in view " + viewDoc);
	} catch (Exception e) {
	    System.err.println("Skipping @match tag due to an internal error '" + tagText
		    + "'" + " in view " + viewDoc);
	    e.printStackTrace();
	}
	return null;
    }
1295321
public Matcher getMatcher(String str) {
                Matcher m;
                if (matchers.containsKey(str)) {
                        m = matchers.get(str);
                } else {
                        m = p.matcher(str);
                        matchers.put(str, m);
                }
                return m;
        }
911165
public static boolean regexMatch(String input, String regex) {
        return Pattern.compile(regex).matcher(input).matches();
    }
194419
def match_type=(match_type)
      validator = EnumAttributeValidator.new('String', ["Exact", "StartsWith", "EndsWith", "Contains"])
      if match_type.to_i == 0
        unless validator.valid?(match_type)
          raise ArgumentError, "invalid value for 'match_type', must be one of #{validator.allowable_values}."
        end
        @match_type = match_type
      else
        @match_type = validator.allowable_values[match_type.to_i]
      end
    end
505459
public String remove(String txt) {
        for (Pattern p : patterns.keySet()) {
            System.out.println("p: "+p);
            System.out.println("b: "+txt);
            txt = p.matcher(txt).replaceAll(patterns.get(p));
            System.out.println("a: "+txt);
        }
        return txt;
    }