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 <br>) is replaced with a single <br />.  The others are
replaced with two <br />s.

Also curious about the need to replace <p></p> with <br /><br />.  I'm not a
CSS guru, but I believe the two are semantically different.  One (the <p />)
is meant to contain text.  The other (<br />) just meant to force a space.

<p></p> 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 <p /> elements with <br /><br /> 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:
>
> <cfset finalDescription =
>
> replace(replace(replace(trim(form.description),"<br>","<br/>","all"),"<p></p
> >","<br /><br />","all"),"<p>","<br /><br />","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?
>
> <cfset finalDescription = replace(trim(form.description), "<br>", "<br />",
> "ALL")>
> <cfset finalDescription = replace(finalDescription, "<p></p>", "<br /><br
> />", "ALL")>
> <cfset finalDescription = replace(finalDescription, "<p>", "<br /><br />",
> "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

Reply via email to