24 ways to impress your friends

Jump to menu

Vote up?

Matthew Somerville

Hooray, a new year! Nice article, good to see non-frameworked JavaScript :-)

One regex gotcha:

* “.” means any character except newline, and w is alphanumeric+underscore – so if your source src attribute was “my-cat.mp4”, then the first line that sets the src attribute would end up putting in “bumper-in.cat”. If you don’t know what your filenames will be apart from the extension, plus you only care about the extension, probably better just to use something like /.(w+)$/

And a couple of regex typos:

* The “w” character classes all appear to be missing their “”, unless you only want to match wwwww.www ;)
* The last regex has “([w]+)” which also should presumably be w+

Hope that’s helpful.