fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.util.regex.*;
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. final String REGEX = "data|you|Us";
  10. final Pattern PATTERN = Pattern.compile(REGEX);
  11. String message = "Hai man how are you ? Give me data which you have fetched as it is very important data to Us";
  12. Matcher matcher = PATTERN.matcher(message);
  13. StringBuffer result = new StringBuffer();
  14. while (matcher.find()) {
  15. String replacement =
  16. matcher.group(0).replaceAll(".", "*");
  17. matcher.appendReplacement(result, replacement);
  18. }
  19. matcher.appendTail(result);
  20. System.out.println(result.toString());
  21.  
  22. }
  23. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
Hai man how are *** ? Give me **** which *** have fetched as it is very important **** to **