Again, this is probably better handled with database queries. But looking at your example, wouldn't it be simpler to replace "*" with space & "*" & space, and likewise with everything not a-z A-Z including cr, lf, etc? Now you have a guarantee that wholematches will work with words.
Bob S > On Aug 7, 2019, at 12:10 , Dr. Hawkins via use-livecode > <use-livecode@lists.runrev.com> 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 > > 5*pay - 2*monthlypay > > and be able to replace “pay" with > > getVal(pay,,,debtor) > > without replacing monthlypay. > > I can’t with any certainty control the order that variables will appear in my > ”raw” formulae (too many ways to blow up!). > > I’ve considered requiring a space before and after, but, again, two many ways > to blow up. > > I could manually parse the line, looking for starts and stops, but it’s both > ugly and asking for obscure bugs. > > 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 can handle a performance penalty, as this routine would run only in the > development version, with the resultant array saved as a stack property in > any shipped version. But I’d still like it to be as fast as I can and avoid > thumb-twiddling . . . > — > Richard E. Hawkins, Esq. > The Hawkins Law Firm > 3430 E. Flamingo Rd. > Suite 232 > Las Vegas, NV 89121 > (702) 508-8462 _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode