import java.io.*;
public class RemoveAha {
public static void main (String [] args) throws IOException {
// Setting up the reading:
// Create a buffered reader
BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
// to read a line of input, use in.readLine();
// prompt the user:
String input = in.readLine();
String result = input.replaceAll("aha","");
System.out.println("Aha! You meant");
System.out.println(result);
System.out.println("When you said");
System.out.println(input);
}
}
This is an example from CSci 1211 course.