I write program, which can recognize the certain word in the string, but i have a question. How to recognize a word in the string without gaps? (in one full string).
String string;
String word;
Scanner scan = new Scanner(System.in);
string = scan.nextLine();
word = scan.nextLine();
if(string.matches(".*\\b" + word +"\\b.*")){
System.out.println("found");
}
else {
System.out.println("Error");
}