import java.util.regex.*; public class Regexp { public static void main(String []args) { String input = "Can you locate all ? (question marks), dollar signs($), carrets(^) or dots(.) in this character sequence"; // Βρες αλφαριθμητικά που αρχίζουν από τον χαρακτήρα '<' και τελειώνουν στον χαρακτήρα '>' Pattern p = Pattern.compile("\\?|\\$|\\^|\\."); //Pattern p = Pattern.compile("[?$^.]"); Matcher m = p.matcher(input); while(m.find()) { System.out.println("Found: "+input.substring(m.start(), m.end()) +", at: "+m.start() ); } } }