I'm sure there is probably a better way... such as a simple regex.. youll need Doom for that one but until then try this...
<cfsavecontent variable="txt"> This is a test of something <a href="test.cfm" title="test">And this is a link</a><br /> This is another test but with an image tag <img src="somimg.jpg" al"" /> so let's see how it goes </cfsavecontent> <cfscript> function noBreak(str) { blockArr = arrayNew(1); while (reFindNoCase("<.*?", str) and reFindNoCase("<.*?", str)) { startPos = reFindNoCase("<.*?", str); endPos = reFindNoCase("<*.?>", str); thisBlock = Mid(str, startPos, endPos - startPos+2); str = removeChars(str, startPos, endPos - startPos+2); ArrayAppend(blockArr, thisBlock); str = Insert("[!*#ArrayLen(blockArr)#*!]", str, startPos - 1); } str = replace(str, ' ', ' ', 'all'); for (i=1; i lte ArrayLen(blockArr); i=i+1) { str = replacenocase(str, '[!*#i#*!]', blockArr[i]); } return str; } </cfscript> <cfoutput>#noBreak(txt)#</cfoutput> ..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com -----Original Message----- From: Rick Faircloth [mailto:[EMAIL PROTECTED] Sent: Thursday, October 11, 2007 9:01 PM To: CF-Talk Subject: How to write this regex? Hi, all. I thought I could figure this out, but apparently not. at least so far. But how would I write a regex that would find all spaces and change them to except those inside a < or > ? REreplace(string, "all spaces not in between < and >", " ", "All") And I'd rather not have an "unbreakable" space, but I couldn't come up with anything else to use. (I gave it a shot Claude!) Suggestions anyone? Rick ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290953 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4