fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. import java.util.regex.*;
  5.  
  6. class Main
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. StringBuilder sb = new StringBuilder();
  11. sb.append("This works with StringBuffers\n");
  12. sb.append("Authorization : Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9\n");
  13. sb.append("etc\n");
  14. Pattern p = Pattern.compile(".*Authorization : Bearer .*");
  15. Matcher m = p.matcher(sb.toString());
  16.  
  17. System.out.println(m.replaceAll("Auth line redacted2"));
  18. //Pattern p = Pattern.matches("Authorization",sb);
  19. //System.out.println(p);
  20. //Matcher m = p.matcher(sb);
  21. //System.out.println(m.matches());
  22. }
  23. }
Success #stdin #stdout 0.11s 55636KB
stdin
Standard input is empty
stdout
This works with StringBuffers
Auth line redacted2
etc