import java.util.regex.*; public class Regexp { public static void main(String []args) { String input = "I allocated \\ room \nfor \t my cat\\"; System.out.println("Input String: "+ input+"\n-------------"); // βρες όλους τους χαρακτήρες TAB ή χαρακτήρες αλλαγής γραμμής \n // ή χαρακτήρες \ (backslash) Pattern p = Pattern.compile("\n|\t|\\\\"); // definition of \ is \\\\ Matcher m = p.matcher(input); while(m.find()) { System.out.println(input.substring(0, m.start())+ " (pos: "+m.start()+","+m.end()+") " + input.substring(m.end())); } } }