I have a regular expression, which matches exact words, if space is in between, it returns false. How can i achieve this? even though I have a space in between or not it has to return true. EX:
var str1 = "This is a fruit";
var str2 = "this is afruit";
str2 = str2.toLowerCase();
if(str2.toLowerCase().match(/a fruit/)){
alert("matched");
return true;
}
return false;
In the above if condition, I have mentioned .match(/a fruit/) it wil return me false because i'm considering space too. I dont want to do like this. Enven if it is "a fruit" or "afruit" it has to return me true. I'm new to regular expression Please help.. I'm stuck here.