Replace every nth character occurrence in Java : <p>I have a rather finnicky and fragile string formatter, where the only way that I can split data entries from a source is to know the size of the entry, and then remove it from the input data.<br>
For example, the output looks something like:  </p>

<pre><code>field1 / field2 / field3 / field4 / 
field1 / field2 / field3 / field4 /
field1 / field2 / field3 / field4 /
</code></pre>

<p>And I would like to split the output on every nth /, in this case every 4th /.<br>
I cannot split based on \n since the output can insert \n characters in order to wrap the output to the screen, and I am not allowed to alter the output code or receive it in another format.  </p>

<p>So far I had the idea of splitting the entire raw input based on /, then assembling every n entries as an object, however I do not feel as if this is a particularly elegant solution.</p>
