fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String input = "melanie rugullies eching trägt dirndl darüber das volksfestmadl stadt freising dürfen begeistern für tanzsport ";
  13. //does not work
  14. input = input.replaceAll("( dürfen )", " ");
  15. input = input.replaceAll("(\\sdürfen\\s)", " ");
  16. input = input.replace(" dürfen ", " ");
  17.  
  18. //works ...
  19. input = input.replaceAll("(\\sdarüber\\s)", " ");
  20. input = input.replaceAll("(\\smöchte\\s)", " ");
  21. //input = input.replace(" dürfen", " "); //works but is not desired ...
  22. System.out.println(input);
  23. }
  24. }
Success #stdin #stdout 0.06s 380160KB
stdin
Standard input is empty
stdout
melanie rugullies eching trägt dirndl das volksfestmadl stadt freising begeistern für tanzsport