I was looking through some PHP code from a third-party vendor recently, and saw something that made my jaw drop. It’s pretty innocent-looking, at first. Here’s a somewhat anonymized and genericized version of the code, but the thing that bothered me is still intact. It’s not really a bug, per se; the code will function as […]
Tag Archives: silly coding tricks
Silly Coding Tricks: “Inverted” String Match
Saturday, February 13th, 2010 – 4:20 pm
First things first: Never actually do this. This is just a fun curiosity, for amusement value only. Because of the way JavaScript’s search() method works, you can do: var my_url = 'http://kai.mactane.org'; if (! my_url.search(/http:\/\/kai.mactane.org/)) { alert("Your URL is http://kai.mactane.org"); } else { alert("Nope, your URL isn't http://kai.mactane.org"); } Try running this, and it will […]