View Full Version : javascript matching problem

06-05-2003, 08:50 PM
I'm trying to match the word describe, and if it is found give an alert. If it is not found then everything is good. The code below doesn't work, how do I change it to catch only the word describe?
if (describe == "describe")
alert ('Do not put "describe" in, this is done automatically');
return false;

06-05-2003, 08:52 PM
so you mean you have a paragraph or some text in a textbox and want to find out if the word describe appears in it?


06-05-2003, 09:09 PM
yes, if it is going to be in this paragraph it will be the first word.

06-05-2003, 09:24 PM
if ( /describe/i.test( describe ) )

06-05-2003, 10:01 PM
beetle, what does the /i.test stand for?
It works, just wondering. Thank you

06-06-2003, 01:47 AM

is a pattern - meaning "Match the word describe, and ignore case"

regular expression patterns can't be summed up quickly. Visit the links provided by liorean in a sticky at the top of this forum for more info.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum