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.
I am trying to keep all my path's relative to the home directory of my website.
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 ../../
Any one know of a good quick easy way to do this?