我将如何解析句子“嗨,你好吗?”中的“嗨”这个词。或解析“你好吗?”中的“如何”一词?
我想要的代码示例:
String word = "hi";
String word2 = "how";
Scanner scan = new Scanner(System.in).useDelimiter("\n");
String s = scan.nextLine();
if(s.equals(word)) {
System.out.println("Hey");
}
if(s.equals(word2)) {
System.out.println("Hey");
}