using regex with replace to replace all instances of something in a string
<p>so you have a string and you want to replace a recurring character, use this to do it:</p>
<p>String Example: <code>var string = "a-string-with-dashes.txt";</code></p>
<pre>
var string = "a-string-with-dashes.txt";
string = string.replace(/-/g , " ");
</pre>
<p><code>string</code> should now = <code>a string with dashes.txt</code></p>
<h2>String Test</h2>
<p>You can edit the following strings to test or just run it to see the result. </p>
<p>String to Replace: <input type='text' value='a-string-with-out-dashes.txt' id='stringtext'></p>
<p>Result: <code><span id='testresult'></span></code></p>
<p><a onclick='testreplacestring();' class='btn btn-primary'>Run Replace</a></p>
<script>
function testreplacestring() {
var stringtext = document.getElementById("stringtext").value;
document.getElementById("testresult").innerHTML = stringtext.replace(/-/g, " ");
}
</script>
