title: How to mock get(id) requests
body: <p>I am building an application prototype and try to mock the REST web-services.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>var mock = angular.module('mock', ['ngMockE2E']);
  mock.run(function($httpBackend){
      users = [{id:1,name:'John'},{id:2,name:'Jack'}];
      $httpBackend.whenGET('/users').respond(users);
      $httpBackend.whenGET(new RegExp('\\/users\\/[0-9]+')).respond(users[0]);
  }
  </code></pre>
  
  <p>Everything is ok, my resource User.query() returns all users, and User.get({id:1}) and User.get({id:2}) returns the same user (John).</p>
  
  <p>Now to improve my prototype, I would like to return the appropriate user, matching the good id. </p>
  
  <p>I read in <a href="http://docs.angularjs.org/api/ngMock/service/%24httpBackend" rel="nofollow">the angular documentation</a> I should be able to replace the RegExp URI by a function. The idea is to extract the id from the url to use it in respond method.
  I then tried this:</p>
  
  <pre><code>$httpBackend.whenGET(new function(url){
      alert(url);
      var regexp = new RegExp('\\/users\\/([0-9]+)'); 
      id = url.match(regexp)[1];  
      return regexp.test(url);
  }).respond(users[id]);
  </code></pre>
  
  <p>The problem is the url parameter is always undefined. Any idea to achieve my goal?</p>