replacing only exact matches in script

Alex Tweedly alex at tweedly.net
Wed Aug 7 21:12:13 EDT 2019


On 07/08/2019 20:10, Dr. Hawkins via use-livecode wrote:

>
> I’m finally writing my new version of dependency calculation for database variables, with a supposedly clever easy format fo entry and machine calculated script.
>
> I need to replace only exact true words, though.   So I need to be able to take an input string such as
>
> ...
> I could make a list of all the truewords, and cycle through, moving any one that is a substring of any other to the end, and repeatedly looping until the list is empty.  Ugly, but the least insane of the options I’ve come up with.
>
I know I haven't understood exactly what you want - so treat this 
carefully ...

It's not difficult to "move any one that is a substring of any other" - 
don't start searching for substrings or you get into an N**2 problem (or 
worse). Just sort the strings 'descending by the number of chars in each'.

Alex.





More information about the Use-livecode mailing list