replace hardcoded strings

This commit is contained in:
mherbaghinyan 2019-01-13 11:35:54 +04:00
parent 06ffe3b5e4
commit 04c6cd1215

View File

@ -56,15 +56,20 @@ public class MatchWords {
.addKeyword(words[1])
.ignoreOverlaps()
.build();
Collection<Emit> emits = trie.parseText(inputString)
.stream()
.filter(e -> !Objects.equals(e.getKeyword(), e.getKeyword()))
.collect(Collectors.toList());
emits.forEach(System.out::println);
return emits.size() == words.length;
}
private static boolean containsWordsPatternMatch(String inputString, String[] words) {
Pattern pattern = Pattern.compile("(?=.*hello)(?=.*Baeldung)");
Pattern pattern = Pattern.compile("(?=.*" + words[0] + ")(?=.*" + words[1] + ")");
if (pattern.matcher(inputString).find()) {
return true;
}