...

View Full Version : returning part of content which matches pattern



jimbob
11-07-2012, 02:40 PM
heres my code so far for my homework


mypages=["www.google.com|google is a very popular search engine.",
"www.bing.com|bing is another search engine.",
"www.ask.com|ask is yet another search engine."
];



//function join(mypages,pattern)
{if(mypages[0].toLowerCase().match(pattern.toLowerCase()))//.match String Object is used to match page with the pattern
return "www.google.com";
else if(mypages[1].toLowerCase().match(pattern.toLowerCase()))
return "www.bing.com" ;
else if(mypages[3].toLowerCase().match(pattern.toLowerCase()))
return "www.ask.com";
else
return "";} //returns an empty string because no match is found



an issue i am having is I have to make it so the search ignores the website when searching eg.
alert(join(mypages,"www.bing.co.uk")
returns ""

it has to ignore the array including the |

any tips?

Philip M
11-07-2012, 03:05 PM
And the point of that is?

The only way would be to obfuscate the array with encryption of some sort.

jimbob
11-07-2012, 03:15 PM
And the point of that is?

The only way would be to obfuscate the array with encryption of some sort.

Could there be an alternative method eg using a loop be more easier?

jmrker
11-07-2012, 05:59 PM
I am unclear of the requirement...

Do you want to do something when a match is found OR do you want to avoid doing something??? :confused:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum