Skip navigation.

exploreopera

| Help

Sign up | Help

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

avatar
Nice P:

By citoyen, # 18. September 2006, 13:58:08

avatar
:-D
nice, very nice…

By Kildor, # 18. September 2006, 15:44:59

avatar
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:

By GKiller, # 18. September 2006, 16:17:11

avatar
lol

Now that's what I call Web 2.0!

By robodesign, # 18. September 2006, 19:17:25

avatar
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:

By xErath, # 18. September 2006, 19:50:16

avatar
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.

By gemsling, # 19. September 2006, 07:12:29

Write a comment

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