Created
February 2, 2017 13:42
-
-
Save thekoushik/d1fb888d68ad12fd62b66f5435e27b11 to your computer and use it in GitHub Desktop.
Javascript String Partial Word Match
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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