For my next stuff I needed the Javascript equivalents of PHP functions basename() and dirname(). Nothing genius: PLAIN TEXT JAVASCRIPT: function basename(path) { return path.replace(/\\/g,'/').replace( /.*\//, '' ); } function dirname(path) { return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');; } It obviously supports paths like /home/ozh/stuff.php, http://site.com/file.ext or double backslashed Win32 paths such as C:\\dir\\document.txt. Edit: Mister Ze in comments points out to [...] → Read more
Archive for April 27th, 2008
This tatoo doesn't even validate, duh! (via the always entertaining pics.reddit) Share This Related posts Insightful Einstein ! (1) Worst Logos Ever (0) Top Ten Tricks to Optimize Wordpress (7) Sorry. Your screen name is already taken ! (2) Sony Digital Cameras Users Love Boobs (3) [...] → Read more