fork download
  1. import java.util.regex.Pattern;
  2. import java.util.regex.Matcher;
  3.  
  4. class Ideone
  5. {
  6. public static void main(String[] asd){
  7. String sourcestring = "ON cONfirmation, put * your hat";
  8. sourcestring = sourcestring.replaceAll("(?<=\\s|^)(ON|\\*N|O\\*|\\*)(?=\\s|$)","").replaceAll(" "," ").trim();
  9. System.out.println("sourcestring=["+sourcestring+"]");
  10. }
  11. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
sourcestring=[cONfirmation, put your hat]