javascript - Check if a sentence or part of a sentence is a inside an other sentence -
i'm trying how sentence inside sentence.
for example
i have 2 sentences:
- "this first"
- "i first "
in example, result want "the first" inside both of sentences.
i want start loop on whole second sentence. mean, first search if "i first " inside "this first". if not, check if "i " inside, if not check "am first". split 2 words , on...until i'm getting match (or not)
what efficient way in js?
you can split both strings array.
var array1 = 'this first'.split(' '); var array2 = 'i first'.split(' ');
now can loop on 1 array , find out if word in array. , if match found put in array , join matched results separated space
Comments
Post a Comment