100% untested, but you get the idea: s = "The project is done."; strings = [ "and dinna spare the whip", "and I sure am handsome", ... ] start = 0; while (true) { // any . ? ! preceded by a letter and followed by a space start = REFind("[a-zA-Z][.?!]( |$)", s, start); if (start == 0) { break; // no match } if (randRange(1, 20) EQ 1) { // 5% chance rs = strings[randRange(1, arrayLen(strings))]; insert(", " & rs, s, start + 1); start += len(rs) + 4; } }
On Thu, Sep 17, 2009 at 10:15 PM, Phillip Vector <vec...@mostdeadlygame.com> wrote: > > Hey people. I'm working on a filter to put in some random text into my > pages. For example... > > The project is done. > > Becomes > > The project is done, and dinna spare the whip! > > (I think some of you know why I am doing this). :) > > Anyway, I don't want to have it appear after EVERY period or ! or ?.. > I'd like to randomly put it (say, 5% chance every sentence). > > I'm thinking about looping over the text, character by character. When > it finds a period, it "rolls the dice" and perhaps does the > replacement based on the last few characters before the period. Then > keeps going. > > Does anyone have a less convoulted way of doing this (or something I > can plug and play into it)? > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326420 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4