How to get word offset all instances of a string in a chunk of text?

Jim Lambert jiml at netrin.com
Thu Aug 30 20:09:44 EDT 2018


> I wrote:
> 
> Then there is also this repeat-less approach using arrays and filter:

> function findWordOffsets pText, pSearchTerm
> 	put replaceText(pText,"\W+"," ") into pText
> 	split pText by space
> 	combine pText with cr and tab
> 	filter pText with "*" & tab & pSearchTerm
> 	sort numeric pText
> 	return pText
> end findWordOffsets

This just doesn’t work in all cases because splitting by space does not assure one is splitting by true words.
:(
Sorry about that.

Jim Lambert




More information about the use-livecode mailing list