Created
September 29, 2018 08:14
-
-
Save coder618/3f0405afefb48520e240982def76cd28 to your computer and use it in GitHub Desktop.
Words matcher
This file contains hidden or 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 words_match ($bigStr,$smallStr ){ | |
var match_words = ''; | |
$bigStr = $bigStr.trim(); | |
$smallStr = $smallStr.trim(); | |
if( $smallStr.indexOf(',') > 0 ){ | |
// If string contain multiple item | |
var sm_array = $smallStr.split(","); | |
match_words = _.filter( sm_array , function(item) { | |
return $bigStr.toLowerCase().match( item.toLowerCase() ); | |
}); | |
}else{ | |
// If string contain one value | |
if($bigStr.indexOf($smallStr) >= 0){ | |
match_words = $smallStr; | |
} | |
} | |
if( match_words.length > 0 ){ | |
return true; | |
}else return false; | |
// console.log(match_words); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment