On Tue, Apr 7, 2009 at 12:48 AM, Peter Boughton <[email protected]> wrote: > >> So... what rules are you working with? Are you saying that any >> leading/trailing zeros should be ignored? >> >> If so, rereplace(string1, '^0*|0*$', '', 'all') should remove >> leading/trailing zeros. > > Hmmmm. Bit inefficient matching with * - that means you're always matching > the positions ^ and $ whether there are any leading/trailing zeros or not. > > ^0+|0+$ would be better - only replacing when zeroes exist. > > It's a small change, but if this comparison is only part of a larger loop, it > might have an impact.
I'm still learning regex, so i'm less concerned with "inefficient" and more concerned with "holy crap it worked" :) I had the "+" in place of the "*" initially, but read something that made me think the * would be better in that case. I probably misunderstood (and don't recall what it was specifically, as I read it late last night and I'm typing this early the next morning), but I think I get what you're saying. The + matches 1 or more, whereas the * matches zero or more... so with the asterisk the engine always "hits" the beginning and end (even in the case of zero zeros). Thanks. Just woke up and learned something. I can go back to bed :) -- I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:321402 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

