use of java.util.regex.Pattern in project lucida by claritylab.
the class TextProcessor method parseAsWeek.
/**
* Returns the date range string by parsing s as a week.
*
* @param s String representing the result of the annotation pipeline
* @param text String representing the original query
*/
private String[] parseAsWeek(String s, String text) {
// Check whether s is like "2016-W23" representing the previous week (a bug in coreNLP?).
Pattern pattern_week = Pattern.compile("[0-9]{4,4}-[0-9]{2,2}-W[0-9]{2,2}");
Matcher matcher_week = pattern_week.matcher(s);
if (matcher_week.find()) {
String[] s_parsed = matcher_week.group(0).split("W");
int week_num = Integer.parseInt(s_parsed[s_parsed.length - 1]);
return new String[] { getDateFromWeek(week_num + 1), getDateFromWeek(week_num + 2) };
}
return null;
}
use of java.util.regex.Pattern in project cucumber-jvm by cucumber.
the class SnippetGenerator method patternFor.
String patternFor(String stepName) {
String pattern = stepName;
for (Pattern escapePattern : ESCAPE_PATTERNS) {
Matcher m = escapePattern.matcher(pattern);
String replacement = Matcher.quoteReplacement(escapePattern.toString());
pattern = m.replaceAll(replacement);
}
for (ArgumentPattern argumentPattern : argumentPatterns()) {
pattern = argumentPattern.replaceMatchesWithGroups(pattern);
}
if (snippet.namedGroupStart() != null) {
pattern = withNamedGroups(pattern);
}
return "^" + pattern + "$";
}
use of java.util.regex.Pattern in project cucumber-jvm by cucumber.
the class FormatterMissingLifecycleMethods method ensure_name_with_spaces_works_with_args.
@Test
public void ensure_name_with_spaces_works_with_args() {
RuntimeOptions options = new RuntimeOptions("--name 'some Name'");
Pattern actualPattern = (Pattern) options.getFilters().iterator().next();
assertEquals("some Name", actualPattern.pattern());
}
use of java.util.regex.Pattern in project cucumber-jvm by cucumber.
the class MetaStepdef method matches.
public boolean matches(String text) {
Pattern p = pattern();
Matcher m = p.matcher(text);
return m.matches() || m.hitEnd();
}
use of java.util.regex.Pattern in project cucumber-jvm by cucumber.
the class FormatterMissingLifecycleMethods method ensure_name_with_spaces_works_with_cucumber_options.
@Test
public void ensure_name_with_spaces_works_with_cucumber_options() {
Properties properties = new Properties();
properties.setProperty("cucumber.options", "--name 'some Name'");
RuntimeOptions options = new RuntimeOptions(new Env(properties), Collections.<String>emptyList());
Pattern actualPattern = (Pattern) options.getFilters().iterator().next();
assertEquals("some Name", actualPattern.pattern());
}
Aggregations