Hi,
I have an input string containing multiple lines(demarcated by \n). I need to search for a pattern in the lines and if its found, then replace the complete line with empty string.
My code looks like this,
Pattern p = Pattern.compile("^.*@@.*$");
String regex = "This is the first line \n" +
"And this is second line\n" +
"Thus is @@{xyz} should not appear \n" +
"This is 3rd line and should come\n" +
"This will not appear @@{abc}\n" +
"But this will appear\n";
Matcher m = p.matcher(regex);
System.out.println("Output: "+m.group());
I expect the response as :
Output: This is the first line
And this is second line
This is 3rd line and should come
But this will appear.
I am unable to get it, please help, me out.
Thanks,
Amit