import java.util.regex.*; public class Regexp { public static void main(String []args) { String input = "Search in google and arrange meetings in doodle"; // Βρες αλφαριθμητικά που αρχίζουν από g ή d ακολουθούν δύο χαρακτήρες o και τελειώνουν σε g ή d. Pattern p = Pattern.compile("[g|d]o{2}[g|d]"); Matcher m = p.matcher(input); while(m.find()) { System.out.println("Found: "+input.substring(m.start(), m.end()) +", at: "+m.start() ); } } }