title: Java replace every Nth specific character (e.g. space) in String
body: <p>I am trying to learn regular expressions and the code below replaces every other whitespace with an underscore but I am trying to replace every third white space.</p>
  
  <pre><code> String replace = deletedWords.replaceAll("(?&lt;!\\G\\w+)\\s","_");
  </code></pre>
  
  <p>Ex. output I get: "I have_been stuck_on this_problem forever" </p>
  
  <p>Ex. output I want: "I have been_stuck on this_problem forever"</p>