title: Regular Expression not matching in JavaScript and AngularJS with ng-change
body: <p>I am trying to get my path variable in this page to change the spaces and punctuation characters, as the user types it in. Here is the corresponding code:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en-US" ng-app&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width"&gt;
      &lt;title&gt;ng-change&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="mystyle.css" media="all"/&gt;
      &lt;script type="text/javascript" src="angular_1.0.7.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
      &lt;body&gt;
          &lt;div class="browser" ng-controller="Browser"&gt;
  
              &lt;!--Mock browser URL--&gt;
              &lt;div class="url"&gt;
                  &amp;larr; &amp;rarr; &amp;infin;
                  &lt;input type="text" value="edit/{{ path }}"/&gt;
              &lt;/div&gt;
  
              &lt;!--Input field for the page, mock page--&gt;
              &lt;div class="page"&gt;
                  &lt;label for="update"&gt;
                      Update the URL:
                      &lt;input ng-change="clean()" ng-model="path"/&gt;
                  &lt;/label&gt;
              &lt;/div&gt;
  
          &lt;/div&gt;
          &lt;script type="text/javascript" src="script.js"&gt;&lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>However, when I type anything in, nothing happens. Here is the script.js file:</p>
  
  <pre><code>var Browser = function ($scope) {
      $scope.clean = function () {
  
          $scope.path = $scope.path
                          .replace("/\s+/g", "-")
                          .replace("/[^a-z0-9-]/i", "");
          console.log($scope.path);
      };
  };
  </code></pre>
  
  <p>I am quite sure I've gotten my javaScript right, but I don't know why exactly my app is not working, I tried debugging it, the problem seems to be that <code>ng-change</code> is only considering it a change when characters other than spaces are put in, whenever spaces are put in, it ignores them.</p>