Finding a substring within a string using regular expressions
You code is pretty much good but

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


may be easily replaced with 

Console br = System.console();


Also your while cycle is endless. I would allow to enter some keyword for breaking the loop. E.g. exit 

...
System.out.println("\nEnter your regex:");
String input = br.readLine();

if ("exit".equals(input)) 
    break;
else {
    Pattern pattern = Pattern.compile(input);
    ...
}