search_words
v1.0.5
Published
search_words package simplifies the searching process with less amount of code
Downloads
3
Maintainers
Readme
Search the words from given string with condition of and or or
A Node.js package that checks whether a given string contains specified search words or not.
Usage
First, install the package using npm:
npm i search_words --save
Then, require the package and use it like so:
var search = require("search_words");
Syntax:
1.search.search_Atleast_One_Word_Match(strArray,"search_words")
2.search.search_Maximum_All_Words_Match(strArray, "search_words");
String Array
var data = [ "Andhra Pradesh Guntur", "Telangana State Hyderabad", "Information Technology", "Computer Science", "Computer Science Engineering", "Mechanical Engineering" ];
Search atleast one word which is match to any position of the string
var result = search.search_Atleast_One_Word_Match(
data,
"Scie AB CD DE A B C D science andhra"
);
console.log(result);
Expected output:
{ criteriaType: 'search_Atleast_One_Word_Match',
givenSearchWordLength: 0,
givenSearchWords: 'Scie AB CD DE A B C D science andhra',
inPut:
[ 'Andhra Pradesh Guntur',
'Telangana State Hyderabad',
'Information Technology',
'Computer Science',
'Computer Science Engineering',
'Mechanical Engineering' ],
matchedCount: 3,
miniumumSearchWordLength: 3,
outPut:
[ 'Andhra Pradesh Guntur',
'Computer Science',
'Computer Science Engineering' ],
searchWords: [ 'scie', 'science', 'andhra' ],
ValidSearchWords: [ 'scie', 'science', 'andhra' ] }
Search word which must be match to total string
var result = search.search_Maximum_All_Words_Match(data, "scie science");
console.log(result);
Expected Output:
{ criteriaType: 'search_Maximum_All_Words_Match',
givenSearchWords: 'scie science',
givenSearchWordLength: 0,
inPut:
[ 'Andhra Pradesh Guntur',
'Telangana State Hyderabad',
'Information Technology',
'Computer Science',
'Computer Science Engineering',
'Mechanical Engineering' ],
miniumumSearchWordLength: 3,
matchedCount: 2,
outPut: [ 'Computer Science', 'Computer Science Engineering' ],
ValidSearchWords: [ 'scie', 'science' ] }