title: How to replace multiple slash and backslash in a string with a single one?
body: <p>My goal is to replace all "/" and "\" with one "\".</p>
  
  <p><strong>Input:</strong></p>
  
  <pre><code>String path = "H\\\\\\\\\\ello///Wo\\rld\\!////";
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>String path = "H\ello\Wo\rld\!\";
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <p>Is there a way to do that all in one single line?</p>
  
  <p>My solution (working!):</p>
  
  <ol>
  <li>change all to the same char</li>
  <li>replace all "/" with one Slash</li>
  <li>put it back to normal</li>
  </ol>
  
  <p>I learned that I need regex and that "[X]+" will put all possible combinations eg. "XXfXfXXXX" to "XfXfX".</p>
  
  <p>I am searching for something like: (pseudocode)</p>
  
  <pre><code>path = path.replaceAll("[\\/]+", "\\");
  </code></pre>
  
  <p>I tried some combinations of that but everytime it throw errors. </p>
  
  <p><strong>My Solution:</strong></p>
  
  <pre><code>path = path.replace("\\", "/");
  path = path.replaceAll("[/]+", "/");
  
  pfad = pfad.replace("/", "\\");
  </code></pre>