title: Converting ampersand (&) and blank space to a dash (-) in URLs using regex
body: <p>With the code below, I have converted the following names into URL such as </p>
  
  <ul>
  <li><code>Love &amp; Relationships</code> to <code>http://domain.org/love-relationships</code></li>
  <li><p><code>Career &amp; Guidance</code> to <code>http://domain.org/career-guidance</code></p>
  
  <pre><code>filter('ampToDash', function(){
      return function(text){
          return text ? String(text).replace(/ &amp; /g,'-'): '';
      };
  }).filter('dashToAmp', function(){
      return function(text){
          return text ? String(text).replace(/-/g,' &amp; '): '';
      };
  })
  </code></pre></li>
  </ul>
  
  <p>However, I have a new set of names and I can't figure out how to do both at the same time.</p>
  
  <ul>
  <li><code>Being Human</code> to <code>http://domain.org/being-human</code></li>
  <li><p><code>Competitive Exams</code> to <code>http://domain.org/competitive-exams</code></p>
  
  <pre><code>filter('ampToDash', function(){
      return function(text){
          return text ? String(text).replace(/ /g,'-'): '';
      };
  }).filter('dashToAmp', function(){
      return function(text){
         return text ? String(text).replace(/-/g,' '): '';
      };
  })
  </code></pre></li>
  </ul>
  
  <p>How do I combine both the regex codes so it can work hand in hand?</p>