fork(1) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3.  
  4.  
  5. class rTest {
  6. public static void main (String[] args) {
  7.  
  8. String s = "I have been stuck on this problem forever quick brown fox jumps over";
  9. String r = s.replaceAll("(?<=(?:^|\\G)\\S*\\s\\S*\\s\\S*)\\s", "_");
  10. System.out.println(r);
  11.  
  12. String x = "I have been stuck on this problem forever quick brown fox jumps over";
  13. String m = x.replaceAll("(?<=(^|\\G)\\S{0,100}\\s\\S{0,100}\\s\\S{0,100})\\s", "_");
  14. System.out.println(m);
  15.  
  16. }
  17. }
Success #stdin #stdout 0.11s 320256KB
stdin
Standard input is empty
stdout
I have been_stuck on this_problem forever quick_brown fox jumps_over
I have been_stuck on this_problem forever quick_brown fox jumps_over