[thelist] CF: Text Formatting Question

Frank lists at frankmarion.com
Tue Jul 22 13:21:41 CDT 2003


At 12:21 PM 2003-07-22 -0500, you wrote:
>And I am well versed enough to know what's going on there.  HOWEVER, some 
>bits of the text need to be in bold for emphasis.  In the text file they 
>gave me, this shows up as  a <bf> tag.  How would I incorporate that 
>formatting into this code?

I'm not quite clear on your question, but I'll take a guess. Paste the 
following into your editor an run it, as a test.


<!---A string to parse --->
    <cfset str="<bf>My Bold Font.</bf> <span>Span text.</span> <bf>Another 
Bold Font.</bf>">

<!--- Replace using non-posix regex --->
    <cfset str2 = REReplaceNoCase(str, "<bf>([a-zA-Z0-9. ]+)</bf>", 
"<strong>\1</strong>" ,"all")>

<!--- Display the results --->
    <cfoutput>
       #str2#<br>
       #HTMLEditFormat(str2)#
    </cfoutput>

Notes
Greedy version: "<bf>([[:print:]]+)</bf>", "<strong>\1</strong>"
Something about the posix version is positively greedy, and I haven't 
figured a way around it yet. The posix classes can be a mixed 
blessing:  Convenient, but imprecise.

Non-Greedy version: "<bf>([a-zA-Z0-9 ]+)</bf>", "<strong>\1</strong>"
This is positively non-greedy, but the downside is that you need to specify 
all the chars that you want to permit. You might want to add your 
punctuation between the [square brackets]




--
Frank Marion     lists at frankmarion.com      Keep the signal high.
If with Yoda so strong is the force , why correct grammar can he not use? 



More information about the thelist mailing list