Answer the question
In order to leave comments, you need to log in
Why does the search term take away the output result?
There is this little code:
if(newMatcher.find()) {
System.out.println("Введите текст в котором хотите совершить поиск : ");
Scanner newScaner = new Scanner(System.in);
String str = newScaner.nextLine();
String text = new String(str);
System.out.println("Теперь введите слово, которое хотите найти");
Scanner newScaner2 = new Scanner(System.in);
String str2 = newScaner.nextLine();
Pattern newPattern = Pattern.compile(str2);
Matcher newMatcher = newPattern.matcher(text);
if(newMatcher.find()) {
while(newMatcher.find()) {
System.out.println(newMatcher.group());
}
}else {
System.out.println("Нет совпадений!");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question