miscoded

the web is a hack

Y!RegExp quiz

, , , ,

This snippet is brought to you by Yahoo!Japan blogs. Quiz of the day: what is the RegExp meant to do and why does it fail?

if(img.match(/(.[jJ][pP][eE]?[gG]|.[gG][iI][fF]|.[pP][nN][gG])/)) {
return true;
}
return false;


(Yes, the variable name is a hint.)

no ballads in this OperaLaunching OddPatch 0.1 Beta

Comments

Eira Monstadcitoyen Monday, September 18, 2006 1:58:08 PM

Nice p

Kostia RomanovKildor Monday, September 18, 2006 3:44:59 PM

:-D
nice, very nice…

GKiller Monday, September 18, 2006 4:17:11 PM

So the dot matches of course any character, and they forgot the $ at the end, and they could have set the i modifier smile

Did I forget something?

Where did the creator learn regular expressions? (or maybe he didn't at all wink

Mihai Sucanrobodesign Monday, September 18, 2006 7:17:25 PM

lol

Now that's what I call Web 2.0!

João EirasxErath Monday, September 18, 2006 7:50:16 PM

That's some peculiar coding
function a(){
  if(foobar)
    return true;
  else
    return false;
}

function b(){
  if( a() )
    return true;
  else
    return false;
}

if( b() )
  return true;
else
  return false;

p

Nathan Jonesgemsling Tuesday, September 19, 2006 7:12:29 AM

I'm guessing they're trying to determine whether a file is an image, but what happens when an image file has a different extension?

BTW, the sign-up process for Opera Community appears to be almost broken/inaccessible: a captcha is presented with mixed case letters, but I couldn't proceed until I entered lowercase equivalents. It should either accept input that exactly matches the captcha, or it should ignore case.

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.