So suppose I have:
String s = \"1479K\"; String t = \"459LP\";
and I want to return
String commonChars = \"49\";
public class common { public static void main(String args[]) { String s = "FIRST"; String s1 = "SECOND"; String common = s.replaceAll("[^" + s1 + "]", ""); System.out.println(common); } }