/** * Determines whether this string matches a given regular expression. * * @param expr the regular expression to be matched. * @return {@code true} if the expression matches, otherwise {@code false}. * @throws PatternSyntaxException if the syntax of the supplied regular expression is not valid. * @throws NullPointerException if {@code expr} is {@code null}. */ public boolean matches(String expr) { return Pattern.matches(expr, this); }
/** * Determines whether this string matches a given regular expression. * * @param expr the regular expression to be matched. * @return {@code true} if the expression matches, otherwise {@code false}. * @throws PatternSyntaxException if the syntax of the supplied regular expression is not valid. * @throws NullPointerException if {@code expr} is {@code null}. */ public boolean matches(String expr) { return Pattern.matches(expr, this); }
private static boolean find(String name, List<String> list) { for (String regexpStr : list) { if (Pattern.matches(regexpStr, name)) { return true; } } return false; } }
/** * 正则表达式匹配 * * @param regex 正则表达式字符串 * @param input 要匹配的字符串 * @return 如果 input 符合 regex 正则表达式格式, 返回true, 否则返回 false; */ public static boolean matches(String regex, String input) { if (null == regex || null == input) { return false; } return Pattern.matches(regex, input); }
private boolean isAggregationDistinctSelectItem(final String innerExpression) { String pattern = "\\(\\s*DISTINCT\\s+.*\\)"; return Pattern.matches(pattern, innerExpression.toUpperCase()); }
/** * Determines whether the regular is matched. * * @param regex regular expression * @param input the string to match. * @return {@code true}: matching<br>{@code false}: mismatching */ public static boolean isMatch(final String regex, final CharSequence input) { return input != null && input.length() > 0 && Pattern.matches(regex, input); }
/** * Determines whether the regular is matched. * * @param regex regular expression * @param input the string to match. * @return {@code true}: matching<br>{@code false}: mismatching */ public static boolean isMatch(final String regex, final CharSequence input) { return input != null && input.length() > 0 && Pattern.matches(regex, input); }
/** * Return whether input matches the regex. * * @param regex The regex. * @param input The input. * @return {@code true}: yes<br>{@code false}: no */ public static boolean isMatch(final String regex, final CharSequence input) { return input != null && input.length() > 0 && Pattern.matches(regex, input); }
@Override public void checkName(String name) { if (StringUtils.isNotBlank(namePattern) && StringUtils.isNotBlank(name)) { if (!Pattern.matches(namePattern, name)) { throw new Failure(StringUtils.isEmpty(description) ? Messages.Hudson_JobNameConventionNotApplyed(name, namePattern) : description); } } }
public TaskDefinition build() { Preconditions.checkArgument(!StringUtils.isEmpty(key), "Task key must be set"); Preconditions.checkArgument(Pattern.matches(KEY_PATTERN, key), "Task key '" + key + "' must match " + KEY_PATTERN); Preconditions.checkArgument(!StringUtils.isEmpty(description), "Description must be set for task '" + key + "'"); Preconditions.checkArgument(taskClass != null, "Class must be set for task '" + key + "'"); return new TaskDefinition(this); } }
/** * * @param groups Array of groups on the method * @param list Map of regexps of groups to be run */ private static boolean isMemberOf(Collection<String> list, String... groups) { for (String group : groups) { for (String o : list) { String regexpStr = methodName(o); if (Pattern.matches(regexpStr, group)) { return true; } } } return false; }
@GET @Produces(MediaType.APPLICATION_JSON) public List<QueryStateInfo> getQueryStateInfos(@QueryParam("user") String user) { List<BasicQueryInfo> queryInfos = queryManager.getQueries(); if (!isNullOrEmpty(user)) { queryInfos = queryInfos.stream() .filter(queryInfo -> Pattern.matches(user, queryInfo.getSession().getUser())) .collect(toImmutableList()); } return queryInfos.stream() .filter(queryInfo -> !queryInfo.getState().isDone()) .map(this::getQueryStateInfo) .collect(toImmutableList()); }
private void assertAllocationFails(Consumer<Void> allocationFunction, String expectedPattern) { try { allocationFunction.accept(null); fail("Expected exception"); } catch (IllegalArgumentException e) { assertTrue(Pattern.matches(expectedPattern, e.getMessage()), "\nExpected (re) :" + expectedPattern + "\nActual :" + e.getMessage()); } }
private boolean isNotAConcrete_NonTest_MaterialConfigImplementation(Class aClass) { return Pattern.matches(".*(Test|Dummy).*", aClass.toString()) || Modifier.isAbstract(aClass.getModifiers()); }
private boolean isCheckCorrectness(QueryPair query) { // Check if either the control query or the test query matches the regex if (Pattern.matches(config.getSkipCorrectnessRegex(), query.getTest().getQuery()) || Pattern.matches(config.getSkipCorrectnessRegex(), query.getControl().getQuery())) { // If so disable correctness checking return false; } else { return config.isCheckCorrectnessEnabled(); } }
public ResourceSet filterByClassnameRegex(String regex) { ResourceSet result = new ResourceSet(); for (Resource r : this) { if (Pattern.matches(regex, r.getClassName())) { result.add(r); } } return result; }
@Test public void understandPatternPunct(){ assertThat(Pattern.matches("a\\.doc","a.doc"), is(true)); assertThat(Pattern.matches("\\p{Punct}","*"), is(true)); assertThat(Pattern.matches("\\p{Punct}","{"), is(true)); assertThat(Pattern.matches("\\p{Punct}","]"), is(true)); assertThat(Pattern.matches("\\p{Punct}","-"), is(true)); assertThat(Pattern.matches("\\p{Punct}","."), is(true)); }
public List<ITestNGMethod> getMethodsThatBelongTo(String group, ITestNGMethod fromMethod) { Set<String> uniqueKeys = m_groups.keySet(); List<ITestNGMethod> result = Lists.newArrayList(); for (String k : uniqueKeys) { if (Pattern.matches(group, k)) { result.addAll(m_groups.get(k)); } } if (result.isEmpty() && !fromMethod.ignoreMissingDependencies()) { throw new TestNGException("DependencyMap::Method \"" + fromMethod + "\" depends on nonexistent group \"" + group + "\""); } else { return result; } }
public ResourceSet filterByNameRegex(String regex) { ResourceSet result = new ResourceSet(); for (Resource r : this) { if (Pattern.matches(regex, r.getResourceId().getName())) { result.add(r); } } return result; }