private static boolean isDml(String queryString, String pattern) { Perl5Matcher matcher = new Perl5Matcher(); if (matcher.matches(queryString, PatternUtils.getPattern(pattern))) { return true; } else { return false; } }
private static DdlResult parseDdl(String queryString, String schmeaName, String pattern, int index) { Perl5Matcher matcher = new Perl5Matcher(); if (matcher.matches(queryString, PatternUtils.getPattern(pattern))) { DdlResult result = parseTableName(matcher.getMatch().group(index), schmeaName); return result != null ? result : new DdlResult(schmeaName); // 无法解析时,直接返回schmea,进行兼容处理 } return null; }
public String findFirst(String originalStr, String regex) { if (StringUtils.isBlank(originalStr) || StringUtils.isBlank(regex)) { return StringUtils.EMPTY; } PatternMatcher matcher = new Perl5Matcher(); if (matcher.contains(originalStr, patterns.get(regex))) { return StringUtils.trimToEmpty(matcher.getMatch().group(0)); } return StringUtils.EMPTY; } }
private String process(String textToParse) { Perl5Matcher matcher = new Perl5Matcher(); PatternMatcherInput input = new PatternMatcherInput(textToParse); PatternCacheLRU pcLRU = new PatternCacheLRU(); Pattern pattern; try { pattern = pcLRU.getPattern(regexpField.getText(), Perl5Compiler.READ_ONLY_MASK); } catch (MalformedCachePatternException e) { return e.toString(); } List<MatchResult> matches = new LinkedList<>(); while (matcher.contains(input, pattern)) { matches.add(matcher.getMatch()); } // Construct a multi-line string with all matches StringBuilder sb = new StringBuilder(); final int size = matches.size(); sb.append("Match count: ").append(size).append("\n"); for (int j = 0; j < size; j++) { MatchResult mr = matches.get(j); final int groups = mr.groups(); for (int i = 0; i < groups; i++) { sb.append("Match[").append(j+1).append("][").append(i).append("]=").append(mr.group(i)).append("\n"); } } return sb.toString(); }
/** * Returns true if the given String is matched by the regular expression of this RegExpEvaluator * * @param value the String to check the production of * @return true if the given string matches the regular expression of this RegExpEvaluator * @see #setExpression **/ public boolean matches(String value) { // object to match compiled regular expressions Perl5Matcher matcher = new Perl5Matcher(); // class for accessing results of pattern match return matcher.contains(value, _regexp); } // -- matches
private int matchStrings(int matchNumber, Perl5Matcher matcher, Pattern pattern, List<MatchResult> matches, int found, String inputString) { PatternMatcherInput input = new PatternMatcherInput(inputString); while (matchNumber <=0 || found != matchNumber) { if (matcher.contains(input, pattern)) { log.debug("RegexExtractor: Match found!"); matches.add(matcher.getMatch()); found++; } else { break; } } return found; }
private boolean isaReplaceAction(String s){ if (pmatcher.matches(s, srPattern)){ return true ; } return false ; } }
GlobCompiler gc = new GlobCompiler(); try { Perl5Pattern pattern = (Perl5Pattern) gc.compile("[JKL][DEF][DEF]"); Perl5Matcher matcher = new Perl5Matcher(); String straw = "JEEVES"; if (matcher.matchesPrefix(straw, pattern)) { MatchResult res = matcher.getMatch(); for (int i = 0; i < res.groups(); i++) { String s = straw.substring(res.beginOffset(i), res.endOffset(i)); // 's' now contains a the match of group #i } } else { // No match } } catch (MalformedPatternException e) { // Oh noes }
String entry = ((String)iter.next()).trim(); MatchResult result = null; if (_preparse_matcher_.matches(entry, _preparse_pattern_)) { result = _preparse_matcher_.getMatch(); String name = result.group(1); String version = result.group(2); String entry = ((String)iter.previous()).trim(); MatchResult result = null; if (_preparse_matcher_.matches(entry, _preparse_pattern_)) { result = _preparse_matcher_.getMatch(); String name = result.group(1); String version = result.group(2);
&& !matcher.matches(newLink.getPath(), patternCache.getPattern("[/]*" + path, // $NON-NLS-1$ Perl5Compiler.READ_ONLY_MASK))) { return false; final String name = item.getName(); if (!query.contains(name + "=")) { // $NON-NLS-1$ if (!(matcher.contains(query, patternCache.getPattern(name, Perl5Compiler.READ_ONLY_MASK)))) { return false;
/** * Does the given argument match the pattern? * @param input the string to match against * @param options the regex options to use * @return true if the pattern matches * @throws BuildException on error */ @Override public boolean matches(final String input, final int options) throws BuildException { return matcher.contains(input, getCompiledPattern(options)); }
/** * Returns a Vector of matched groups found in the argument. * * <p>Group 0 will be the full match, the rest are the * parenthesized subexpressions</p>. * * @param input the string to match against * @param options the regex options to use * @return the vector of groups * @throws BuildException on error */ @Override public Vector<String> getGroups(final String input, final int options) throws BuildException { if (!matches(input, options)) { return null; } final Vector<String> v = new Vector<>(); final MatchResult mr = matcher.getMatch(); final int cnt = mr.groups(); for (int i = 0; i < cnt; i++) { String match = mr.group(i); // treat non-matching groups as empty matches if (match == null) { match = ""; } v.add(match); } return v; }
@Override protected Perl5Matcher initialValue() { return new Perl5Matcher(); } };
logger.debug("Watch started..."); stopWatch.start(); Perl5Matcher matcher = new Perl5Matcher(); int i; while (true) { String input = buffer.toString(); logger.debug("Input: " + input.replace("\r", "[\\r]").replace("\n", "\\n")); if (matcher.contains(input, regExpMatch.getPattern())) { MatchResult result = matcher.getMatch(); buffer = new StringBuffer(); buffer.append(input.substring(result.beginOffset(0) + result.end(0)));
/** * Returns true if the given String is matched by the * regular expression of this RegExpEvaluator * * @param value the String to check the production of * @return true if the given string matches the regular * expression of this RegExpEvaluator * @see #setExpression **/ public boolean matches(String value) { // object to match compiled regular expressions Perl5Matcher matcher = new Perl5Matcher(); // class for accessing results of pattern match return matcher.contains(value,_regexp); } //-- matches
public List<String> getAllMatches(String content, String spattern, int group) throws MalformedPatternException { List<String> list = new ArrayList<String>(); PatternMatcherInput input = new PatternMatcherInput(content); Pattern pattern = patterns.addPattern(spattern); while (this.matcher.contains(input, pattern)) { MatchResult result = this.matcher.getMatch(); String smatch = result.group(group); list.add(smatch); } return list; }
/** * Hack to make matcher clean the two internal buffers it keeps in memory which size is equivalent to * the unzipped page size * @param matcher {@link Perl5Matcher} * @param pattern Pattern */ public static void clearMatcherMemory(Perl5Matcher matcher, Pattern pattern) { try { if (pattern != null) { matcher.matches("", pattern); // $NON-NLS-1$ } } catch (Exception e) { // NOOP } }
} else if (pmatcher.matches(action,srPattern)){ System.out.println("hop: "+ pmatcher.getMatch().group(1)); try { Pattern pt = pcompiler.compile(pmatcher.getMatch().group(1), Perl5Compiler.DEFAULT_MASK); String newvalue = pmatcher.getMatch().group(2); if (pmatcher.matches(atts,pt)){ String repl = putil.substitute(action, atts); System.out.println("replaced: "+atts+" by: "+repl);
/** * By default, the method assumes the entry is not included, unless it * matches. In that case, it will return true. * * @param text text to be checked * @return <code>true</code> if text is included */ protected boolean incPattern(String text) { this.USEFILE = false; for (Pattern includePattern : this.INCPATTERNS) { if (JMeterUtils.getMatcher().contains(text, includePattern)) { this.USEFILE = true; break; } } return this.USEFILE; }