Skip to content

Instantly share code, notes, and snippets.

@thekoushik
Created February 2, 2017 13:42
Show Gist options
  • Save thekoushik/d1fb888d68ad12fd62b66f5435e27b11 to your computer and use it in GitHub Desktop.
Save thekoushik/d1fb888d68ad12fd62b66f5435e27b11 to your computer and use it in GitHub Desktop.
Javascript String Partial Word Match
function wordMatch(s1,s2){
var a1=s1.toLowerCase().split(/[^A-Za-z]/);
var a2=s2.toLowerCase().split(/[^A-Za-z]/);
for(var i=0;i<a1.length;i++)
if(a2.indexOf(a1[i])>=0)
return true;
return false;
}
var str1="Kolkata, West Bengal, India";
var str2="goa,west";
console.log(wordMatch(str1,str2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment