import java.util.regex.*; public class Regexp { public static void main(String []args) { String input = "I allocated room for my cat"; // βρες όλες τις αλληλουχίες χαρακτήρων cat μέσα στο αλφαριθμητικό. Pattern p = Pattern.compile("cat"); 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())); } } }