nl_tokens: Returns the indices of a string in a text . If it is found multiple times it will return multiple indices .
pl_tokens: function getIndicesByWord ( word , text ) { var startIndex = 0 ; var searchStringLength = word . length ; var index , indices = [ ] ; while ( ( index = text . indexOf ( word , startIndex ) ) > - 1 ) { // Check if the previous and next character are word boundaries to determine if a complete word was detected var isPreviousCharacterWordBoundary = characterInBoundary ( text [ index - 1 ] ) || index === 0 ; var isNextCharacterWordBoundary = characterInBoundary ( text [ index + searchStringLength ] ) || ( text . length === <mask> + searchStringLength ) ; if ( isPreviousCharacterWordBoundary && isNextCharacterWordBoundary ) { indices . push ( { index : index , match : word , } ) ; } startIndex = index + searchStringLength ; } return indices ; }