It will match partial results
You can search multiple terms in one search
Search terms can be, string values, string byref and array of strings byref
All search terms from all sources are agglomerated, and then each term in the search list is scanned for in the input array
All matches are appended to an array if it already exists
Suppose you have this array
Code: Select all
set "testArray[0]=apple"
set "testArray[1]=banana"
set "testArray[2]=cherry"
set "testArray[3]=banana apple"
set "testArray[4]=grape apple"
set "testArray.lbound=0"
set "testArray.ubound=4"
Code: Select all
call :SearchArrayForString testArray searchResults apple banana
Code: Select all
:LoopResults
if defined searchResults[%index%] (
echo !searchResults[%index%]!
set /a "index+=1"
goto :LoopResults
)
Code: Select all
apple
banana apple
grape apple
banana
banana apple
The output result array are not true "tuples" however, I found it cleaner to only put the index in .index
Code: Select all
D:\dev\work>set se
searchResults=0
searchResults.lbound=0
searchResults.ubound=4
searchResults[0]=apple
searchResults[0].index=0
searchResults[1]=banana apple
searchResults[1].index=3
searchResults[2]=grape apple
searchResults[2].index=4
searchResults[3]=banana
searchResults[3].index=1
searchResults[4]=banana apple
searchResults[4].index=3
TODO
Make a version, or parameter, that only returns exact matches
This function could be faster
Search could be more parametrable
Here is the DEMO file