title: Reg ex that parses window.location.pathname and returns number of /s
body: <p>I am looking for a regex pattern (and have been unable to come up with one) that can parse window.location.pathname and return the number of /s in it.</p>
  
  <p>I am trying to keep all my path's relative to the home directory of my website.</p>
  
  <p>For example: index.html has a script tag with an src="js/scripts.js". But that doesn't work if I access /episode/10/index.html. The path js/scripts.js is no longer valid. So my method is to write a simple javascript find and replace and return the number of /s in window.location.pathname. Subtract that number by 1 and change all the src to something like ../../</p>
  
  <p>Any one know of a good quick easy way to do this?</p>