I want to replace text "1\n2" ("1" new line and "2")with for example "abcd". I've been searching a lot for solution but I can't find.
Below is my code
String REGEX = "1\n2";
Pattern p = Pattern.compile(REGEX, Pattern.DOTALL);
Matcher m = p.matcher(text);
String newText = m.replaceAll("abcd");
[EDIT] I'd like to add that text variable is read from file:
String text = new Scanner(new File("...")).useDelimiter("\\A").next();