title: Powershell replace spaces and special characters with hyphen
body: <p>I want to replace any special characters and spaces in a string with hyphen. 
  Below is my code:</p>
  
  <pre><code>$c = 'This_is my code !@# characters are not $ allowed% remove spaces ^&amp;*(){}[]/_:;,.?/"'''
  $c = $c -replace [regex]::Escape('!@#$%^&amp;*(){}[]/:;,.?/"'),('-')
  Write-Host $c
  </code></pre>
  
  <p>Is there any direct way to find all special characters, spaces and replace with a single character hyphen</p>