Re: Regex Help - Can this be simplified?
The easiest to read solution is one line: Of course, that function will then contain a nicely spaced easy-to-read piece of logic, which almost certainly wont be a horrible single line of nested replaces. ~| 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:325495 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex Help - Can this be simplified?
You don't actually need a regex to put this into one easily read line: replaceList(trim(finalDesription), ',,,', ',,,') ... Or some derivative there of. Performance may differ slightly in favour of one way or another, but as much as I love regexs and I use them frequently, they're rarely easy to descipher at a glance. Gabriel -Original Message- From: Tony Bentley [mailto:t...@tonybentley.com] Sent: Friday, 14 August 2009 5:59 AM To: cf-talk Subject: Re: Regex Help - Can this be simplified? You're better off using regex-replace(){rereplace()} over replace() for more than one condition. The pipe is a way to cheat the replace function but for future string searching or replacing functions, try regex and you can even test it online here: http://www.cftopper.com/contentfiles/tools/regularExpTester.cfm >There ya go. :) Just found out you can use the pipe "|" as well. > >rereplace(string,"()+()","","all") ~| 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:325447 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Regex Help - Can this be simplified?
You're better off using regex-replace(){rereplace()} over replace() for more than one condition. The pipe is a way to cheat the replace function but for future string searching or replacing functions, try regex and you can even test it online here: http://www.cftopper.com/contentfiles/tools/regularExpTester.cfm >There ya go. :) Just found out you can use the pipe "|" as well. > >rereplace(string,"()+()","","all") ~| 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:325446 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Regex Help - Can this be simplified?
There ya go. :) Just found out you can use the pipe "|" as well. -Original Message- From: Tony Bentley [mailto:t...@tonybentley.com] Sent: Thursday, August 13, 2009 2:35 PM To: cf-talk Subject: Re: Regex Help - Can this be simplified? rereplace(string,"()+()","","all") ~| 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:325444 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Regex Help - Can this be simplified?
Sorry I didn't read the post very well rereplace(form.description,"()+()+()","","all") This does not replace a single with but I think it does the job. ~| 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:325443 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Regex Help - Can this be simplified?
Easy there, killer. You said "A". I said "B". You didn't preface it with "in my opinion" any more than I did. I still maintain that (in my opinion), it's preferable to write more legible code. The single line may be just as easily readable for you, but you may not always be the one maintaining your code. On Thu, Aug 13, 2009 at 11:40 AM, Dave Phillips < experiencedcfdevelo...@gmail.com> wrote: > > This, of course, is completely a matter of opinion. I prefer 1 line - > faster processing, and still easy to support. Again, that's MY opinion, > and > I'm sure we have about a hundred other opinions on this list. There's no > doubt that there are many ways to accomplish something in ColdFusion. But > an alternate method should not be shot down as "not simplified" especially > when the provider of the alternate method was just trying to help. > > Dave Phillips > > -Original Message- > From: Charlie Griefer [mailto:charlie.grie...@gmail.com] > Sent: Thursday, August 13, 2009 1:29 PM > To: cf-talk > Subject: Re: Regex Help - Can this be simplified? > > > less lines != simplified :) > > A year from now, which version are you going to want to come back to when > it > needs work? The 3 line version or the 1? > > I'd prefer the 3. Easier to read. > > > ~| 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:325442 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Regex Help - Can this be simplified?
rereplace(string,"()+()","","all") ~| 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:325441 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Regex Help - Can this be simplified?
This, of course, is completely a matter of opinion. I prefer 1 line - faster processing, and still easy to support. Again, that's MY opinion, and I'm sure we have about a hundred other opinions on this list. There's no doubt that there are many ways to accomplish something in ColdFusion. But an alternate method should not be shot down as "not simplified" especially when the provider of the alternate method was just trying to help. Dave Phillips -Original Message- From: Charlie Griefer [mailto:charlie.grie...@gmail.com] Sent: Thursday, August 13, 2009 1:29 PM To: cf-talk Subject: Re: Regex Help - Can this be simplified? less lines != simplified :) A year from now, which version are you going to want to come back to when it needs work? The 3 line version or the 1? I'd prefer the 3. Easier to read. ~| 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:325440 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex Help - Can this be simplified?
Charlie, think of my problem like this. Say you had any 5 character combos you wanted to remove, for whatever reason. I'm just looking for a simpler (or so I thought) RegEx way to do this. I could loop over a list, but I thought (perhaps naively) there might be a Regex function that could accepta a list of chars and then replace any of them when a match was found. -Original Message- From: Charlie Griefer [mailto:charlie.grie...@gmail.com] Sent: Thursday, August 13, 2009 2:29 PM To: cf-talk Subject: Re: Regex Help - Can this be simplified? less lines != simplified :) A year from now, which version are you going to want to come back to when it needs work? The 3 line version or the 1? I'd prefer the 3. Easier to read. Not really sure a regex solution is warranted here. You could probably get one whipped up to find all instances of the tag combinations that you want... but not all instances are replaced with the same string. Only the first one (the ) is replaced with a single . The others are replaced with two s. Also curious about the need to replace with . I'm not a CSS guru, but I believe the two are semantically different. One (the ) is meant to contain text. The other () just meant to force a space. will give you more flexibility via CSS to style individual paragraphs. You might not have that need now, which is fine. But by replacing all elements with you're effectively giving up that flexibility forever. ~| 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:325438 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Regex Help - Can this be simplified?
less lines != simplified :) A year from now, which version are you going to want to come back to when it needs work? The 3 line version or the 1? I'd prefer the 3. Easier to read. Not really sure a regex solution is warranted here. You could probably get one whipped up to find all instances of the tag combinations that you want... but not all instances are replaced with the same string. Only the first one (the ) is replaced with a single . The others are replaced with two s. Also curious about the need to replace with . I'm not a CSS guru, but I believe the two are semantically different. One (the ) is meant to contain text. The other () just meant to force a space. will give you more flexibility via CSS to style individual paragraphs. You might not have that need now, which is fine. But by replacing all elements with you're effectively giving up that flexibility forever. On Thu, Aug 13, 2009 at 11:19 AM, Dave Phillips < experiencedcfdevelo...@gmail.com> wrote: > > I'm not an expert with Regex, but you could do this: > > > replace(replace(replace(trim(form.description),"","","all")," >","","all"),"","","all") > > > Again, this is not regex, but it is a much more simplified (and faster I > believe) way of doing the same thing with 1 line of code. > > Dave Phillips > -Original Message- > From: Che Vilnonis [mailto:ch...@asitv.com] > Sent: Thursday, August 13, 2009 1:14 PM > To: cf-talk > Subject: Regex Help - Can this be simplified? > > > Is there a way using CF's Regex functions to simplfy the lines of code > below > into one line? Some kind of built in regex list comparison maybe? > > ", "", > "ALL")> > ", " />", "ALL")> > ", "", > "ALL")> > > Thanks, CV > > > > ~| 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:325437 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Regex Help - Can this be simplified?
I'm not an expert with Regex, but you could do this: ","","all"),"","","all"),"","","all") > Again, this is not regex, but it is a much more simplified (and faster I believe) way of doing the same thing with 1 line of code. Dave Phillips -Original Message- From: Che Vilnonis [mailto:ch...@asitv.com] Sent: Thursday, August 13, 2009 1:14 PM To: cf-talk Subject: Regex Help - Can this be simplified? Is there a way using CF's Regex functions to simplfy the lines of code below into one line? Some kind of built in regex list comparison maybe? ", "", "ALL")> ", "", "ALL")> ", "", "ALL")> Thanks, CV ~| 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:325436 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4