Re: rereplace for removing repeating characters
I am sure there are some nice slick regular expressions to do this, but I just simply do this a very dumbed down way. cfset myVar = ReplaceNoCase(myVar , ,, ,, ALL) cfset myVar = ReplaceNoCase(myVar , , ,, ALL) cfset myVar = ReplaceNoCase(myVar , ,, ALL) cfset myVar = ReplaceNoCase(myVar , ,,, ,, ALL) You could also write a loop to run until FindNoCase(myVar, ,,) EQ FALSE, so you keep turning double commas, into single commas which will continue to reduce the commas, until there are no matches. Again, there is probably a RegEx way to do this, but I don't know RegEx off the top of my head. Regards, David McGraw Oyova Software, LLC http://www.oyova.com On Tue, Nov 2, 2010 at 8:34 AM, Richard White rich...@j7is.co.uk wrote: Hi, i need to replace all repeating commas in a string with only one comma, plus remove the trailing comma, have tried a few different routes unsuccessfully and would appreciate any input: for example i would the the string: 'Genns,,DrBish Stratford,,,' to become: 'Genns,Dr,Bish Stratford' thanks ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:338748 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: rereplace for removing repeating characters
thanks for the reply, i actually just found a shortcut! i converted the string to an array which removed any empty array elements, and then converted back to a list and therefore deleted all the duplicate, and trailing commas I am sure there are some nice slick regular expressions to do this, but I just simply do this a very dumbed down way. cfset myVar = ReplaceNoCase(myVar , ,, ,, ALL) cfset myVar = ReplaceNoCase(myVar , , ,, ALL) cfset myVar = ReplaceNoCase(myVar , ,, ALL) cfset myVar = ReplaceNoCase(myVar , ,,, ,, ALL) You could also write a loop to run until FindNoCase(myVar, ,,) EQ FALSE, so you keep turning double commas, into single commas which will continue to reduce the commas, until there are no matches. Again, there is probably a RegEx way to do this, but I don't know RegEx off the top of my head. Regards, David McGraw Oyova Software, LLC http://www.oyova.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:338750 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: rereplace for removing repeating characters
try this: cfset string = rereplace(rereplace(string, ,+$, ), ,+, ,, all) Azadi On 02/11/2010 20:34 , Richard White wrote: Hi, i need to replace all repeating commas in a string with only one comma, plus remove the trailing comma, have tried a few different routes unsuccessfully and would appreciate any input: for example i would the the string: 'Genns,,DrBish Stratford,,,' to become: 'Genns,Dr,Bish Stratford' thanks ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:338751 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: REReplace Statment Help
This will replace everything that is not alphanumeric with a dash: ProductPageName = rereplace( Form.PageName , '\W' , '-' , 'All' ) However, the above will change this that to this---that, if you would prefer a single dash in situations like this, you can simply do this: ProductPageName = rereplace( Form.PageName , '\W+' , '-' , 'All' ) \W in that regex stands for non-word-character, equivalent in CF to [^a-zA-Z0-9_] ~| 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:327496 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace Statment Help
There are 2 separate thing being done with that code. 1. Its replacing spaces with a - 2. Its removing a bunch of 'special' characters. There really is no way to do this in one live of code. However, if this is something you woudl need to use in more than one place, you can easily put these two lines of code into a UDF. On Wed, Oct 21, 2009 at 11:07 AM, Glyn Jackson glyn.jack...@newebia.co.uk wrote: I am just going over some old code, I found the following... productPageName = Replace(#FORM.pageName#, ,-,All); productPageName = REReplace(#productPageName#,[.*+?^${}()|[\]/\\],,All); its seems like its create a page name but removed spaces and special characters i.e. this page! becomes this-page cumbersome, any better ways of doing this, maybe one line of code and not two, or a function about this does this? Thanks Glyn ~| 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:327440 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REReplace Statment Help
If you want it in one line, just combine them: productPageName = Replace(REReplace(FORM.pageName,[.*+?^${}()|[\]/\\],,All), ,-,All); BTW, you don't the the #'s inside of a function unless the variable is in quotes. Thanks, Eric Cobb http://www.cfgears.com Glyn Jackson wrote: I am just going over some old code, I found the following... productPageName = Replace(#FORM.pageName#, ,-,All); productPageName = REReplace(#productPageName#,[.*+?^${}()|[\]/\\],,All); its seems like its create a page name but removed spaces and special characters i.e. this page! becomes this-page cumbersome, any better ways of doing this, maybe one line of code and not two, or a function about this does this? Thanks Glyn ~| 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:327443 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REReplace Statment Help
Makes sense, thanks you. ~| 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:327452 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace Statment Help
also, if you are replace all non alpha-numeric characters you can do this:reReplace(arguments.txt, '[^[:alnum:].]', '-', 'all'); ~Mahcsig On Wed, Oct 21, 2009 at 8:57 AM, Glyn Jackson glyn.jack...@newebia.co.ukwrote: Makes sense, thanks you. ~| 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:327473 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REreplace function for special characters
[q] FileName = rereplace(FileName, '(?!\.[^.]*$)\W', '', 'all') [/q] well, that is just beautiful! Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ ~| 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:316752 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REreplace function for special characters
hmm... i guess i forgot to paste in the rest of the code... here it is in all its ugly gory: cfset filename = rereplace(left(filename, len(filename)-len(listlast(filename, .))-1), \W, , all) . listlast(filename, .) it may be eugh and ugly!, but it's a one-liner and takes care of . inside filenames and any file extension length :) if you still feel eugh about that one, how about this one: cfset filename = reverse(rereplace(listrest(reverse(filename), .), \W, , all)) . listlast(filename, .) since this one is a tad bit shorter, will you consider it, maybe, just ugly or just eugh? :) or how about this rereplace-only one: cfset filename = rereplace(rereplace(filename, (.+?)(\.[^.]*$|$), \1), \W, , all) rereplace(filename, (.+?)(\.[^.]*$|$), \2) (filename splitting regex courtesy of http://www.movingtofreedom.org/2008/04/01/regex-match-filename-base-and-extension/) :P Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ Peter Boughton wrote: better then just do something like rereplace(left(filename, len(filename)-len(listlast(filename, .)-1), \W, , all) Eugh. Ugly! And doesn't restore the extension afterwards, so my-image-name.png would become myimagename instead of myimagename.png. ~| 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:316687 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REreplace function for special characters
but it's a one-liner So? Unless you have a limited number of newlines, mindlessly shoving commands into a single line is really dumb; it reduces readability and achieves nothing. This is another thing that bugs me - people compressing code without thought - having the right amount of whitespace in the right places is good for you! takes care of . inside filenames and any file extension length Well yeah, the original spec was dealing with images, which in general have a limited set of extensions, so extension length wasn't so much an issue. But yes, something to work for all filenames could be useful to people. All the ones you gave, (aside from being /UGLY/ :P), will not work for several common filenames - try running .htaccess and README through them, for example. Of course, I have come up with a one-line solution, but not by shunting together multiple commands. :P FileName = rereplace( FileName , '(?!\.[^.]*$)\W' , '' , 'all' ) Strips all non-word characters, excluding the final dot (if any). Although, thinking a bit more... for general purpose use, I might not bother stripping dots, or hyphens, or tilde, so might end up with this instead: FileName = rereplace( FileName , '(?!\.[^.]|[-~])\W' , '' , 'all' ) ~| 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:316730 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REreplace function for special characters
better then just do something like rereplace(left(filename, len(filename)-len(listlast(filename, .)-1), \W, , all) Eugh. Ugly! And doesn't restore the extension afterwards, so my-image-name.png would become myimagename instead of myimagename.png. ~| 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:316611 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REreplace function for special characters
My follow-up posted last night didn't show up. So, I'm re-doing it now. Execellent, Peter, thank you very much. I'll use rereplace( FileName , '\W' , '' , 'all' ) On the extension stuff I have a way to address it. Don rereplace(foo, '[^\w]', '', 'all') will replace any non-alphanumeric character No need to complicate things with an inverted character class. \W is same as [^\w] Also, this bugs me immensely: assuming 'foo' is the file name JUST USE THE VARIABLE FILENAME THEN! So: rereplace( FileName , '\W' , '' , 'all' ) ~| 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:316653 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REreplace function for special characters
rereplace(foo, '[^\w]', '', 'all') will replace any non-alphanumeric character in 'foo' (assuming 'foo' is the file name). On Wed, Dec 10, 2008 at 1:41 PM, Don L [EMAIL PROTECTED] wrote: Regular Expression gurus. How to use the REreplace function to remove special characters including +, . in an image file name? The ReplaceList function may miss some unexpected special characters for we don't know what sort of special character may show up in a dynamically generated image file with special characters. Many thanks. ~| 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:316579 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REreplace function for special characters
rereplace(foo, '[^\w]', '', 'all') will replace any non-alphanumeric character in 'foo' (assuming 'foo' is the file name). On Wed, Dec 10, 2008 at 1:41 PM, D Great. Thank you. I also found out that REreplace(str, [^a-zA-Z0-9],,all) would achieve the same result but yours seems more elegant (which seems to say just keep {words}), my CF env = cf8 or cf81 for Windows, does your solution have any dependency? ~| 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:316581 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REreplace function for special characters
rereplace(foo, '[^\w]', '', 'all') will replace any non-alphanumeric character No need to complicate things with an inverted character class. \W is same as [^\w] Also, this bugs me immensely: assuming 'foo' is the file name JUST USE THE VARIABLE FILENAME THEN! So: rereplace( FileName , '\W' , '' , 'all' ) ~| 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:316582 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REreplace function for special characters
On Wed, Dec 10, 2008 at 3:02 PM, Peter Boughton [EMAIL PROTECTED] wrote: rereplace(foo, '[^\w]', '', 'all') will replace any non-alphanumeric character No need to complicate things with an inverted character class. \W is same as [^\w] fair enough. good catch. Also, this bugs me immensely: assuming 'foo' is the file name JUST USE THE VARIABLE FILENAME THEN! So: rereplace( FileName , '\W' , '' , 'all' ) bah. i like foo :P -- 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:316584 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REreplace function for special characters
Hmmm, another thought... Don, when you say image file name, is there a file extension to worry about (i.e. jpg/png/etc) If so, you'll want to be doing something like this... rereplace( FileName , '(png|jpg|gif|tif|bmp)$' , '.\0' ) after the initial replacement, to restore the dot that will otherwise be stripped. (If you're manually adding the extension later, it doesn't matter) ~| 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:316585 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REreplace function for special characters
I also found out that REreplace(str, [^a-zA-Z0-9], ,all) would achieve the same result but yours seems more elegant (which seems to say just keep {words}), my CF env = cf8 or cf81 for Windows, does your solution have any dependency? No dependency. \W [^\w] and [^a-zA-Z0-9] will all work in all CFML versions/engines worth worrying about They are all standard regex constructs. However, it is worth pointing out that \w has a slightly different meaning amongst different regex engines - it means word character, rather than alphanumeric. In CFML/rereplace it is treated as [a-zA-Z0-9_] (not the underscore). However, in some flavours of regex \w will accept accented/etc characters (e.g. á ç ÿ ) - so if this code was used in something other than CFML, you might need to use the version that explicitly specifies standard letters+digits. ~| 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:316586 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REreplace function for special characters
Sorry, typo. :( In CFML/rereplace it is treated as [a-zA-Z0-9_] (not the underscore). That should say note rather than not. Underscore is included in \w (and excluded from \W) which is not what some people might expect/want. ~| 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:316587 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REreplace function for special characters
better then just do something like rereplace(left(filename, len(filename)-len(listlast(filename, .)-1), \W, , all) Azadi Saryev Sabai-dee.com http://www.sabai-dee.com/ Peter Boughton wrote: Hmmm, another thought... Don, when you say image file name, is there a file extension to worry about (i.e. jpg/png/etc) If so, you'll want to be doing something like this... rereplace( FileName , '(png|jpg|gif|tif|bmp)$' , '.\0' ) after the initial replacement, to restore the dot that will otherwise be stripped. (If you're manually adding the extension later, it doesn't matter) ~| 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:316597 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REReplace to avoid HTML elements
we ultimately came up with this: (?![/]#Variables.Word#)(\W)(#Variables.Word#)(\W) The only downside that we found is if the word is at the very end or beginning of the paragraph. That's the \W bits you're using - they're wrong; you want a zero-width word boundary, not a non-word character. Use \b(#Variables.Word#)\b and you wont need to do the workaround. ~| 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:314936 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace to avoid HTML elements
Thanks, I will try that out locally and make a note to apply it the next time I am in there since I already initiated the push process to get the changes into place. On Fri, Nov 7, 2008 at 8:03 AM, Peter Boughton [EMAIL PROTECTED] wrote: we ultimately came up with this: (?![/]#Variables.Word#)(\W)(#Variables.Word#)(\W) The only downside that we found is if the word is at the very end or beginning of the paragraph. That's the \W bits you're using - they're wrong; you want a zero-width word boundary, not a non-word character. Use \b(#Variables.Word#)\b and you wont need to do the workaround. ~| 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:314937 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace to avoid HTML elements
That's the \W bits you're using - they're wrong; you want a zero-width word boundary, not a non-word character. Use \b(#Variables.Word#)\b and you wont need to do the workaround. Thanks Peter... I'd never used word boundaries... so of course, they don't occur to me when I go to write a regex. :) I'll have to remember that in the future. -- s. isaac dealey ^ new epoch isn't it time for a change? ph: 781.769.0723 http://onTap.riaforge.org/blog ~| 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:314944 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace to avoid HTML elements
The \b actually did not work, it put the link within the first span element but maybe was how I tested it. I tried: (?![/]sub)(\b)(sub)(\b) as well as (?![/]sub)\b(sub)\b On Fri, Nov 7, 2008 at 10:49 AM, s. isaac dealey [EMAIL PROTECTED] wrote: That's the \W bits you're using - they're wrong; you want a zero-width word boundary, not a non-word character. Use \b(#Variables.Word#)\b and you wont need to do the workaround. Thanks Peter... I'd never used word boundaries... so of course, they don't occur to me when I go to write a regex. :) I'll have to remember that in the future. -- s. isaac dealey ^ new epoch isn't it time for a change? ph: 781.769.0723 http://onTap.riaforge.org/blog ~| 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:314947 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace to avoid HTML elements
The \b actually did not work, it put the link within the first span element but maybe was how I tested it. I tried: (?![/]sub)(\b)(sub)(\b) as well as (?![/]sub)\b(sub)\b Ah, you need to change your \2 to \1 in your replace part. Since the \b is zero-width, it looks like it wont populate a backreference even when wrapped in parens. Infact, if you wanted, you could go a step further and use \0 along with (?![/]sub)\bsub\b ~| 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:314950 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace to avoid HTML elements
I have been using REReplace to find key words or group of words within paragraphs and if found to replace those with an HREF. The following code works. (I haven't yet decided whether it's entirely the best way though...) cfset Content = ListToArray(Content,'')/ cfloop index=i from=1 to=#ArrayLen(Content)# cfif ListLen(Content[i],'') GT 1 cfset Segment = ListFirst(Content[i],'')/ cfset word = sub/ cfset Segment = linkifyText( Segment , Word , 'Display.cfm?Term='UrlEncodedFormat(Word) ) / cfset Content[i] = Segment '' ListRest(Content[i],'')/ /cfif /cfloop cfset Content = ArrayToList(Content,'')/ cffunction name=linkifyText returntype=String output=false cfargument name=Text type=String/ cfargument name=Word type=String/ cfargument name=Target type=String/ cfreturn rereplace(Arguments.Text,'\b#Arguments.Word#\b','a href=#Arguments.Target#\0/a','all')/ /cffunction ~| 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:314914 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: REReplace to avoid HTML elements
Thanks Peter, I got to talking to Isaac Dealey this evening about this since he had helped out a while back on this particular project. He mentioned what I need is a lookahead in the regex. After a few tries this is what we ultimately came up with this: (?![/]#Variables.Word#)(\W)(#Variables.Word#)(\W) The only downside that we found is if the word is at the very end or beginning of the paragraph. So I will prepend and append a period to the paragraph then run the regex and then pull out the periods. Wish I had clued into that because maybe one of my attempts earlier today would have worked had my test data not had the word at the very end of the paragraph with no period after it. On Thu, Nov 6, 2008 at 1:13 PM, Peter Boughton [EMAIL PROTECTED] wrote: I have been using REReplace to find key words or group of words within paragraphs and if found to replace those with an HREF. The following code works. (I haven't yet decided whether it's entirely the best way though...) cfset Content = ListToArray(Content,'')/ cfloop index=i from=1 to=#ArrayLen(Content)# cfif ListLen(Content[i],'') GT 1 cfset Segment = ListFirst(Content[i],'')/ cfset word = sub/ cfset Segment = linkifyText( Segment , Word , 'Display.cfm?Term='UrlEncodedFormat(Word) ) / cfset Content[i] = Segment '' ListRest(Content[i],'')/ /cfif /cfloop cfset Content = ArrayToList(Content,'')/ cffunction name=linkifyText returntype=String output=false cfargument name=Text type=String/ cfargument name=Word type=String/ cfargument name=Target type=String/ cfreturn rereplace(Arguments.Text,'\b#Arguments.Word#\b','a href=#Arguments.Target#\0/a','all')/ /cffunction ~| 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:314925 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: ReReplace
Not sure why you're using ReReplace, just use Replace. Characters like . have special meanings in ReReplace. On 04/05/07, Robert Rawlins - Think Blue [EMAIL PROTECTED] wrote: I'm trying to replace the .jpg file extension on in a string with .gif and using the following regex. cfset LOCAL.New = 'D:\MediaStore\' REReplace(ARGUMENTS.File, '.jpg', '.gif', 'ALL') / ARGUMENTS.File is a string that looks like 'myfile.jpg' Am I missing something here? Thanks, Rob ~| ColdFusion MX7 and Flex 2 Build sales marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:277038 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: ReReplace
Thanks Adrian, Its working fine now. Rob -Original Message- From: Adrian [mailto:[EMAIL PROTECTED] Sent: 04 May 2007 16:01 To: CF-Talk Subject: Re: ReReplace Not sure why you're using ReReplace, just use Replace. Characters like . have special meanings in ReReplace. On 04/05/07, Robert Rawlins - Think Blue [EMAIL PROTECTED] wrote: I'm trying to replace the .jpg file extension on in a string with .gif and using the following regex. cfset LOCAL.New = 'D:\MediaStore\' REReplace(ARGUMENTS.File, '.jpg', '.gif', 'ALL') / ARGUMENTS.File is a string that looks like 'myfile.jpg' Am I missing something here? Thanks, Rob ~| Create Web Applications With ColdFusion MX7 Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:277039 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: ReReplace
I think you want Replace(), not ReReplace(). ReReplace is trying to use a RegEx to make the replacement, Replace will do the straight text match/replace. I'm trying to replace the .jpg file extension on in a string with .gif and using the following regex. cfset LOCAL.New = 'D:\MediaStore\' REReplace(ARGUMENTS.File, '.jpg', '.gif', 'ALL') / ARGUMENTS.File is a string that looks like 'myfile.jpg' Am I missing something here? Thanks, Rob ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 MX7 integration create powerful cross-platform RIAs http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:277044 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: ReReplace Duh
Change your regex to this [[:space:],] That should work. On 11/29/06, Les Mizzell [EMAIL PROTECTED] wrote: I don't know why, but I always get a headache when working with ReReplace and RegEx stuff... OK, I need to replace *all* spaces with a +: REReplace (#request.mySTRING#,[[:space:]],+,ALL) That works fine. But ... and there's always a but - I need to replace all commas too. They just need to go away and the space they were occupying closed up. Not sure how to get it to do both without doing TWO in-series ReReplace statements. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262089 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: ReReplace Duh
as far as i can tell, it -would- be two rereplace() statements. you're looking to replace two elements with two different elements. it would be different if, let's say you wanted to replace all spaces and commas with a single element (either a space or nothing)...but you're looking to do two different things entirely: 1) replace all spaces with plus characters 2) replace all commas with nothing (effectively remove all commas) the latter could be done with a replace() statement (as opposed to rereplace())...but as I see it, it's still 2 function calls (unless you wrap those two functions behind a single UDF, which might improve readability) On 11/29/06, Les Mizzell [EMAIL PROTECTED] wrote: I don't know why, but I always get a headache when working with ReReplace and RegEx stuff... OK, I need to replace *all* spaces with a +: REReplace (#request.mySTRING#,[[:space:]],+,ALL) That works fine. But ... and there's always a but - I need to replace all commas too. They just need to go away and the space they were occupying closed up. Not sure how to get it to do both without doing TWO in-series ReReplace statements. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262091 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: ReReplace Duh
Oh shoot, sorry. I missed the requirement to change spaces to + and commas to nothing. replaceList may work as well. Although you can't use [:space:] in that case. On 11/29/06, Charlie Griefer [EMAIL PROTECTED] wrote: as far as i can tell, it -would- be two rereplace() statements. you're looking to replace two elements with two different elements. it would be different if, let's say you wanted to replace all spaces and commas with a single element (either a space or nothing)...but you're looking to do two different things entirely: 1) replace all spaces with plus characters 2) replace all commas with nothing (effectively remove all commas) the latter could be done with a replace() statement (as opposed to rereplace())...but as I see it, it's still 2 function calls (unless you wrap those two functions behind a single UDF, which might improve readability) On 11/29/06, Les Mizzell [EMAIL PROTECTED] wrote: I don't know why, but I always get a headache when working with ReReplace and RegEx stuff... OK, I need to replace *all* spaces with a +: REReplace (#request.mySTRING#,[[:space:]],+,ALL) That works fine. But ... and there's always a but - I need to replace all commas too. They just need to go away and the space they were occupying closed up. Not sure how to get it to do both without doing TWO in-series ReReplace statements. ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262093 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: ReReplace Duh
On 11/29/06, Charlie Griefer [EMAIL PROTECTED] wrote: as far as i can tell, it -would- be two rereplace() statements. I'm not as crazy as I thought then. Yup, using two statements works great... cfset request.noSPACE = REReplace(#mySTRING#,[[:space:]],+,ALL) cfset request.myADDRESS = REReplace(#request.noSPACE#ALL) OK, where's the Elmer's so I can put that missing hair back... ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262096 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: ReReplace Duh
One tip - your second statement isn't a regex. It would make more sense to just use replace, not rereplace. On 11/29/06, Les Mizzell [EMAIL PROTECTED] wrote: On 11/29/06, Charlie Griefer [EMAIL PROTECTED] wrote: as far as i can tell, it -would- be two rereplace() statements. I'm not as crazy as I thought then. Yup, using two statements works great... cfset request.noSPACE = REReplace(#mySTRING#,[[:space:]],+,ALL) cfset request.myADDRESS = REReplace(#request.noSPACE#ALL) OK, where's the Elmer's so I can put that missing hair back... ~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262102 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: REReplace
I just tried it and it works for me. Can you post the arguments.body for us to take a look at the mail body? ... Ben Nadel Web Developer Nylon Technology 6 West 14th Street New York, NY 10011 212.691.1134 212.691.3477 fax www.nylontechnology.com Vote for Pedro -Original Message- From: Mike | NZSolutions Ltd [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 30, 2005 10:59 PM To: CF-Talk Subject: REReplace Hi there, I wish to remove the img tags from an article for email purposes. I have... cfset mail_content = REReplaceNoCase(arguments.body, (img [^]+), Image removed - please log into website to view, all) However, this doesn't seem to be working ?? mike ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:225810 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: ReReplace Strange Crap in mySQL Text Field
Barney Boisvert wrote: REreplace is a CF function, not a MySQL function, which is why you're getting the error. MySQL has a 'replace' function though. Something like this should work: UPDATE myDATE SET textfield = replace(textfield, Õ,') That gives a syntax error as well. MySQL Documentation shows single quotes: textfield = replace(textfield, 'Õ',''') That errors as well -- --- Les Mizzell ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:223823 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: ReReplace Strange Crap in mySQL Text Field
OK, running the below directly in the database worked fine. UPDATE `textfield` SET `Logline` = REPLACE(`textfield`,Õ,') Can't get an equilivent Coldfusion query to work though. Ideas? -- --- Les Mizzell ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:223824 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: ReReplace Strange Crap in mySQL Text Field
textfield = replace(textfield, 'Õ',''') That errors as well You cannot use the same character (single quote) as a string and its delimiter in the same time. Check wih the MySQL syntax for escaping single quotes. Then you probabily need to use the preserveSingleQuotes() function in the SQL statement. Not trivial indeed. -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:223833 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: ReReplace Strange Crap in mySQL Text Field
REreplace is a CF function, not a MySQL function, which is why you're getting the error. MySQL has a 'replace' function though. Something like this should work: UPDATE myDATE SET textfield = replace(textfield, Õ,') Rip out part of the table into a temp table to test against so you can ensure it works first: CREATE TEMPORARY TABLE testTable SELECT * FROM myDATE LIMIT 5 cheers, barneyb On 11/9/05, Les Mizzell [EMAIL PROTECTED] wrote: I've been handed a mySQL database with weird stuff in some text fields: Õ instead of ' - for example or things like ÒSet For LifeÓ for left and right quotes I'd like to run a query and remove all these using rereplace, but a test query like the below is returning an error cfloop query=myQUERY cfquery UPDATE myDATE SET textfield = REReplace(#textfield#,Õ,') Where ID = #ID# /cfquery /cfloop There's a massive amount of data, and I'm a little nervous running something that's going to make so many changes... -- --- Les Mizzell -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 100 invites. ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:223795 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reReplace()
thank you pascal... although, im not sure if im even going to travel down the path i was originally thinking on this one... either way, THANKS! -- tony Tony Weeg macromedia certified coldfusion mx developer email: tonyweeg [at] gmail [dot] com blog: http://www.revolutionwebdesign.com/blog/ cool tool: http://www.antiwrap.com ~| Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net http://www.cfhosting.net Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187618 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: reReplace()
If you want to delete cr/lf: REReplace(str,\r?\n,,all) This is CFMX only (this should take care of cr/lf on windows AND lf on *nix). I never used a Mac, but if I understood correctly, \n will take care of cr on a Mac. For CF5, use #chr(13)#?#chr(10)# (this won't take care of mac, although I might be wrong) Pascal -Original Message- From: Tony Weeg [mailto:[EMAIL PROTECTED] Sent: 13 December 2004 22:31 To: CF-Talk Subject: Re: reReplace() i know how to use the reReplace to replace characters and stuff, but what about removing special things, like cr + lf, can you do that in regex? ben :) anyone... thanks. tony On Mon, 13 Dec 2004 16:22:45 -0500, Tony Weeg [EMAIL PROTECTED] wrote: hi there. i need to remove all carriage returns and white space from the contents of a cfsavecontent. one problem. however, there are some *good* #Chr(13)##Chr(10)# that i want to keep. so, what i was thinking, is to put something like #Chr(0)# at each *good* spot then after i replace all cf+lf and white space, ill drop #Chr(13)##Chr(10)# where i find all #chr(0)#'s although this doesnt seem to be too non-kludgy... so, any idea how i can remove all crappy whitespace and cr+lf from a cfsavecontent's value? all of this will end up in a csv file, which explains why i need all the crap removed.. thanks! -- tony Tony Weeg macromedia certified coldfusion mx developer email: tonyweeg [at] gmail [dot] com blog: http://www.revolutionwebdesign.com/blog/ cool tool: http://www.antiwrap.com -- tony Tony Weeg macromedia certified coldfusion mx developer email: tonyweeg [at] gmail [dot] com blog: http://www.revolutionwebdesign.com/blog/ cool tool: http://www.antiwrap.com ~| Special thanks to the CF Community Suite Silver Sponsor - New Atlanta http://www.newatlanta.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187516 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reReplace()
so this reads: reReplace(string,'#chr(10)#|#chr(13)#|#chr(32)#','','all' replace all 10's 13's and 32's regardless of anything is there a way to say, dont remove where you find a (couplet) #chr(10)##chr(13)# just where you find either that arent together? -- tony Tony Weeg macromedia certified coldfusion mx developer email: tonyweeg [at] gmail [dot] com blog: http://www.revolutionwebdesign.com/blog/ cool tool: http://www.antiwrap.com ~| Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net http://www.cfhosting.net Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187465 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reReplace()
rereplace(string ,(\s)[\1\s]+,\1all) Might that do the trick? Thats gonna replace any space character that is followed by another space character (or more) with just the first space char found...or atleast tthats what I was goiong for not positive on the syntax and nothing to check with ATM... Adam H On Mon, 13 Dec 2004 16:44:07 -0500, Tony Weeg [EMAIL PROTECTED] wrote: so this reads: reReplace(string,'#chr(10)#|#chr(13)#|#chr(32)#','','all' replace all 10's 13's and 32's regardless of anything is there a way to say, dont remove where you find a (couplet) #chr(10)##chr(13)# just where you find either that arent together? -- tony Tony Weeg macromedia certified coldfusion mx developer email: tonyweeg [at] gmail [dot] com blog: http://www.revolutionwebdesign.com/blog/ cool tool: http://www.antiwrap.com ~| Special thanks to the CF Community Suite Silver Sponsor - CFDynamics http://www.cfdynamics.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187468 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
RE: reReplace()
Just use #Chr(10)# inside the regex (in a set of brackets or alone) and it'll be turned into it's ascii equivalent for use by the expression. -Original Message- From: Tony Weeg [mailto:[EMAIL PROTECTED] Sent: Monday, December 13, 2004 4:31 PM To: CF-Talk Subject: Re: reReplace() i know how to use the reReplace to replace characters and stuff, but what about removing special things, like cr + lf, can you do that in regex? ben :) anyone... thanks. tony On Mon, 13 Dec 2004 16:22:45 -0500, Tony Weeg [EMAIL PROTECTED] wrote: hi there. i need to remove all carriage returns and white space from the contents of a cfsavecontent. one problem. however, there are some *good* #Chr(13)##Chr(10)# that i want to keep. so, what i was thinking, is to put something like #Chr(0)# at each *good* spot then after i replace all cf+lf and white space, ill drop #Chr(13)##Chr(10)# where i find all #chr(0)#'s although this doesnt seem to be too non-kludgy... so, any idea how i can remove all crappy whitespace and cr+lf from a cfsavecontent's value? all of this will end up in a csv file, which explains why i need all the crap removed.. thanks! -- tony Tony Weeg macromedia certified coldfusion mx developer email: tonyweeg [at] gmail [dot] com blog: http://www.revolutionwebdesign.com/blog/ cool tool: http://www.antiwrap.com -- tony Tony Weeg macromedia certified coldfusion mx developer email: tonyweeg [at] gmail [dot] com blog: http://www.revolutionwebdesign.com/blog/ cool tool: http://www.antiwrap.com ~| Special thanks to the CF Community Suite Silver Sponsor - RUWebby http://www.ruwebby.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187464 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reReplace()
i know how to use the reReplace to replace characters and stuff, but what about removing special things, like cr + lf, can you do that in regex? ben :) anyone... thanks. tony On Mon, 13 Dec 2004 16:22:45 -0500, Tony Weeg [EMAIL PROTECTED] wrote: hi there. i need to remove all carriage returns and white space from the contents of a cfsavecontent. one problem. however, there are some *good* #Chr(13)##Chr(10)# that i want to keep. so, what i was thinking, is to put something like #Chr(0)# at each *good* spot then after i replace all cf+lf and white space, ill drop #Chr(13)##Chr(10)# where i find all #chr(0)#'s although this doesnt seem to be too non-kludgy... so, any idea how i can remove all crappy whitespace and cr+lf from a cfsavecontent's value? all of this will end up in a csv file, which explains why i need all the crap removed.. thanks! -- tony Tony Weeg macromedia certified coldfusion mx developer email: tonyweeg [at] gmail [dot] com blog: http://www.revolutionwebdesign.com/blog/ cool tool: http://www.antiwrap.com -- tony Tony Weeg macromedia certified coldfusion mx developer email: tonyweeg [at] gmail [dot] com blog: http://www.revolutionwebdesign.com/blog/ cool tool: http://www.antiwrap.com ~| Special thanks to the CF Community Suite Silver Sponsor - RUWebby http://www.ruwebby.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187463 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reReplace()
reReplace(string,'(#chr(10)##chr(13)#)|(#chr(10)#|#chr(13)#|#chr(32)#)','\1','all' Tony Weeg wrote: so this reads: reReplace(string,'#chr(10)#|#chr(13)#|#chr(32)#','','all' replace all 10's 13's and 32's regardless of anything is there a way to say, dont remove where you find a (couplet) #chr(10)##chr(13)# just where you find either that arent together? -- Umer Farooq Octadyne Systems [EMAIL PROTECTED] +1 (519) 772-5424 voice +1 (519) 635-2795 mobile +1 (208) 275-3824 fax LOOKING FOR A USED CAR IN IOWA VISIT: http://www.IowaMotors.com WARNING: --- The information contained in this document and attachments is confidential and intended only for the person(s) named above. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution, or any other use of the information is strictly prohibited. If you have received this document by mistake, please notify the sender immediately and destroy this document and attachments without making any copy of any kind. ~| Special thanks to the CF Community Suite Silver Sponsor - New Atlanta http://www.newatlanta.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187486 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reReplace()
its a backreference.. to (#chr(10)##chr(13)#) following page will explain better then I can. http://www.regular-expressions.info/brackets.html Tony Weeg wrote: thank you umer... now, what does the \1 mean in the 3rd parameter? thanks. tony On Mon, 13 Dec 2004 19:02:10 -0500, Umer Farooq [EMAIL PROTECTED] wrote: reReplace(string,'(#chr(10)##chr(13)#)|(#chr(10)#|#chr(13)#|#chr(32)#)','\1','all' Tony Weeg wrote: so this reads: reReplace(string,'#chr(10)#|#chr(13)#|#chr(32)#','','all' replace all 10's 13's and 32's regardless of anything is there a way to say, dont remove where you find a (couplet) #chr(10)##chr(13)# just where you find either that arent together? -- Umer Farooq Octadyne Systems [EMAIL PROTECTED] +1 (519) 772-5424 voice +1 (519) 635-2795 mobile +1 (208) 275-3824 fax LOOKING FOR A USED CAR IN IOWA VISIT: http://www.IowaMotors.com WARNING: --- The information contained in this document and attachments is confidential and intended only for the person(s) named above. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution, or any other use of the information is strictly prohibited. If you have received this document by mistake, please notify the sender immediately and destroy this document and attachments without making any copy of any kind. ~| Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net http://www.cfhosting.net Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187498 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: reReplace()
thank you umer... now, what does the \1 mean in the 3rd parameter? thanks. tony On Mon, 13 Dec 2004 19:02:10 -0500, Umer Farooq [EMAIL PROTECTED] wrote: reReplace(string,'(#chr(10)##chr(13)#)|(#chr(10)#|#chr(13)#|#chr(32)#)','\1','all' Tony Weeg wrote: so this reads: reReplace(string,'#chr(10)#|#chr(13)#|#chr(32)#','','all' replace all 10's 13's and 32's regardless of anything is there a way to say, dont remove where you find a (couplet) #chr(10)##chr(13)# just where you find either that arent together? -- Umer Farooq Octadyne Systems [EMAIL PROTECTED] +1 (519) 772-5424 voice +1 (519) 635-2795 mobile +1 (208) 275-3824 fax LOOKING FOR A USED CAR IN IOWA VISIT: http://www.IowaMotors.com WARNING: --- The information contained in this document and attachments is confidential and intended only for the person(s) named above. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution, or any other use of the information is strictly prohibited. If you have received this document by mistake, please notify the sender immediately and destroy this document and attachments without making any copy of any kind. ~| Special thanks to the CF Community Suite Silver Sponsor - RUWebby http://www.ruwebby.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:187494 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations Support: http://www.houseoffusion.com/tiny.cfm/54
Re: rereplace ?
I'm confused on a number of issues. First, I don't know what characters you're referring to.But that's tangental, anyway. Second, I don't know why you need a regular _expression_.You could just use a regular replace for each one: string = replace(string, chr(123), chr(456), 'all') where 123 and 456 represent the ascii values of the characters you have and you want, respectively. --Ben dave wrote: i have 3 damn chr's that r giving me fits trying to remove from an output string. they are getting there from copy paste from a mac the 3 chr's are em ~ needs to be a ' fs ~ needs to be gs ~ can i do it all in 1 calling or do i need 3? i been trying both but not working tia dave [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: rereplace ?
I'm confused on a number of issues. sorry ben but i dont know why u live in kentucky either HAHA jk ;) First, I don't know what characters you're referring to. http://www.asciitable.com./ i think im just getting mixed up on what value to use for example for em do i use (in the chr()) em or 25 or 19 or 031? (in the chart on above link) dave ~not sweatin my arse off in the ky heat anymore :)~ -- Original Message -- From: Ben Doom [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] Date:Thu, 26 Aug 2004 16:33:15 -0400 I'm confused on a number of issues. First, I don't know what characters you're referring to.But that's tangental, anyway. Second, I don't know why you need a regular _expression_.You could just use a regular replace for each one: string = replace(string, chr(123), chr(456), 'all') where 123 and 456 represent the ascii values of the characters you have and you want, respectively. --Ben [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: rereplace ?
25 Bryan Stevenson B.Comm. VP Director of E-Commerce Development Electric Edge Systems Group Inc. phone: 250.480.0642 fax: 250.480.1264 cell: 250.920.8830 e-mail: [EMAIL PROTECTED] web: www.electricedgesystems.com - Original Message - From: dave To: CF-Talk Sent: Thursday, August 26, 2004 1:45 PM Subject: Re: rereplace ? I'm confused on a number of issues. sorry ben but i dont know why u live in kentucky either HAHA jk ;) First, I don't know what characters you're referring to. http://www.asciitable.com./ i think im just getting mixed up on what value to use for example for em do i use (in the chr()) em or 25 or 19 or 031? (in the chart on above link) dave ~not sweatin my arse off in the ky heat anymore :)~ -- Original Message -- From: Ben Doom [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] Date:Thu, 26 Aug 2004 16:33:15 -0400 I'm confused on a number of issues. First, I don't know what characters you're referring to.But that's tangental, anyway. Second, I don't know why you need a regular _expression_.You could just use a regular replace for each one: string = replace(string, chr(123), chr(456), 'all') where 123 and 456 represent the ascii values of the characters you have and you want, respectively. --Ben [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: rereplace ?
I'm confused on a number of issues. sorry ben but i dont know why u live in kentucky either HAHA jk ;) My family lives here.Trust me, that's the *only* reason.Rural KY is not that fun a place. First, I don't know what characters you're referring to. http://www.asciitable.com./ i think im just getting mixed up on what value to use for example for em do i use (in the chr()) em or 25 or 19 or 031? (in the chart on above link) I see now.I wasn't sure what you were referring to by 'em' at first. In this case, you'd use 25.Use the decimal ascii value. --Ben [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: REReplace: Manipulating Backreferences
Not directly, that I've ever been able to figure out.What I have done (though it's kind of a pain) is to use refind to grab out the bits I want, and do something like string = left(string, pos[1] - 1) emailAntiSpam(mid(string, pos[1], len[1])) right(string, pos[1]+len[1]+1, len(string)); Loop over this until pos[1] = 0; Ugly, but it works. Not that it will probably help you do what you're trying to do.:-( --Ben Doom Jamie Jackson wrote: I just wrote a UDF to do a rereplace with manipulated backreference values. Specifically, it replaces all instances of email addresses in a string with antiSpam email addresses. However, I'm wondering if there was an easier way... Is there any magic shortcut, similar to this (illegal) pseudo-code? (i.e. Is there a way to manipulate the backreferenced value within the rereplace function?) rereplace(str, ([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+, emailAntiSpam(\1), all); Thanks, Jamie [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: REReplace: Manipulating Backreferences
Yeah, I've already got the UDF written, I was just thinking how nice it would be if I could manipulate the backreference directly. It would simplify the code a lot. Thanks, Jamie On Thu, 05 Feb 2004 13:50:27 -0500, in cf-talk you wrote: Not directly, that I've ever been able to figure out.What I have done (though it's kind of a pain) is to use refind to grab out the bits I want, and do something like string = left(string, pos[1] - 1) emailAntiSpam(mid(string, pos[1], len[1])) right(string, pos[1]+len[1]+1, len(string)); Loop over this until pos[1] = 0; Ugly, but it works. Not that it will probably help you do what you're trying to do.:-( --Ben Doom Jamie Jackson wrote: I just wrote a UDF to do a rereplace with manipulated backreference values. Specifically, it replaces all instances of email addresses in a string with antiSpam email addresses. However, I'm wondering if there was an easier way... Is there any magic shortcut, similar to this (illegal) pseudo-code? (i.e. Is there a way to manipulate the backreferenced value within the rereplace function?) rereplace(str, ([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+, emailAntiSpam(\1), all); Thanks, Jamie [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: REReplace: Manipulating Backreferences
Yeah you can use back references, it would be something like the following Pseudo code: your spam email = taco at coldfusionist.com find (\.*)\sat\s(\.*) replace with [EMAIL PROTECTED] The regex needs adjustment, but it displays how the back references could do the trick Taco Fleur Bloghttp://www.tacofleur.com/index/blog/ http://www.tacofleur.com/index/blog/ Methodology http://www.tacofleur.com/index/methodology/ Tell me and I will forget Show me and I will remember Teach me and I will learn -Original Message- From: Jamie Jackson [mailto:[EMAIL PROTECTED] Sent: Friday, 6 February 2004 4:32 AM To: CF-Talk Subject: REReplace: Manipulating Backreferences I just wrote a UDF to do a rereplace with manipulated backreference values. Specifically, it replaces all instances of email addresses in a string with antiSpam email addresses. However, I'm wondering if there was an easier way... Is there any magic shortcut, similar to this (illegal) pseudo-code? (i.e. Is there a way to manipulate the backreferenced value within the rereplace function?) rereplace(str, ([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+, emailAntiSpam(\1), all); Thanks, Jamie _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: REReplace: Manipulating Backreferences
That's not quite what I've got going on. Notice that while you used backreferences, you didn't *process* them at all. (Maybe that's how I should have phrased it: Is it possible to *process* backreferences within REReplace?) Please remember that AFAIK, what I'm asking about is impossible, but I was just making sure. Also, please note that I don't need help getting this to work in another way (i.e. with a loop), as I have already made a UDF that does it the hard way. cfsavecontent variable=myString [EMAIL PROTECTED] hello [EMAIL PROTECTED] goodbye /cfsavecontent cfscript // keep in mind that this is just illegal pseudocode myString = rereplace(str, ([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+, emailAntiSpam(\1), all); /cfscript cfoutput #myString# /cfoutput ### DESIRED YIELD ### #102;#111;o#64;#98;a#114;#46;c#111;#109; hello #106;#105;m#64;#106;a#109;#46;c#111;#109; goodbye Thanks, Jamie On Fri, 6 Feb 2004 06:11:30 +1000, in cf-talk you wrote: Yeah you can use back references, it would be something like the following Pseudo code: your spam email = taco at coldfusionist.com find (\.*)\sat\s(\.*) replace with [EMAIL PROTECTED] The regex needs adjustment, but it displays how the back references could do the trick Taco Fleur Bloghttp://www.tacofleur.com/index/blog/ http://www.tacofleur.com/index/blog/ Methodology http://www.tacofleur.com/index/methodology/ Tell me and I will forget Show me and I will remember Teach me and I will learn -Original Message- From: Jamie Jackson [mailto:[EMAIL PROTECTED] Sent: Friday, 6 February 2004 4:32 AM To: CF-Talk Subject: REReplace: Manipulating Backreferences I just wrote a UDF to do a rereplace with manipulated backreference values. Specifically, it replaces all instances of email addresses in a string with antiSpam email addresses. However, I'm wondering if there was an easier way... Is there any magic shortcut, similar to this (illegal) pseudo-code? (i.e. Is there a way to manipulate the backreferenced value within the rereplace function?) rereplace(str, ([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+, emailAntiSpam(\1), all); Thanks, Jamie _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: REReplace: Manipulating Backreferences
You are exactly correct, the replace string is processed for all CF content BEFORE it is passed to the actual REreplace function.So there's no way to do anything with the stuff the backreference matches except stick it in the replace string somewhere. Cheers, barneyb -Original Message- From: Jamie Jackson [mailto:[EMAIL PROTECTED] Sent: Thursday, February 05, 2004 12:43 PM To: CF-Talk Subject: Re: REReplace: Manipulating Backreferences That's not quite what I've got going on. Notice that while you used backreferences, you didn't *process* them at all. (Maybe that's how I should have phrased it: Is it possible to *process* backreferences within REReplace?) Please remember that AFAIK, what I'm asking about is impossible, but I was just making sure. Also, please note that I don't need help getting this to work in another way (i.e. with a loop), as I have already made a UDF that does it the hard way. cfsavecontent variable=myString [EMAIL PROTECTED] hello [EMAIL PROTECTED] goodbye /cfsavecontent cfscript // keep in mind that this is just illegal pseudocode myString = rereplace(str, ([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+, emailAntiSpam(\1), all); /cfscript cfoutput #myString# /cfoutput ### DESIRED YIELD ### #102;#111;o#64;#98;a#114;#46;c#111;#109; hello #106;#105;m#64;#106;a#109;#46;c#111;#109; goodbye Thanks, Jamie [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: REReplace: Manipulating Backreferences
Great, that's the info I needed! :D Thanks, Jamie On Thu, 5 Feb 2004 12:52:54 -0800, in cf-talk you wrote: You are exactly correct, the replace string is processed for all CF content BEFORE it is passed to the actual REreplace function.So there's no way to do anything with the stuff the backreference matches except stick it in the replace string somewhere. Cheers, barneyb -Original Message- From: Jamie Jackson [mailto:[EMAIL PROTECTED] Sent: Thursday, February 05, 2004 12:43 PM To: CF-Talk Subject: Re: REReplace: Manipulating Backreferences That's not quite what I've got going on. Notice that while you used backreferences, you didn't *process* them at all. (Maybe that's how I should have phrased it: Is it possible to *process* backreferences within REReplace?) Please remember that AFAIK, what I'm asking about is impossible, but I was just making sure. Also, please note that I don't need help getting this to work in another way (i.e. with a loop), as I have already made a UDF that does it the hard way. cfsavecontent variable=myString [EMAIL PROTECTED] hello [EMAIL PROTECTED] goodbye /cfsavecontent cfscript // keep in mind that this is just illegal pseudocode myString = rereplace(str, ([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+, emailAntiSpam(\1), all); /cfscript cfoutput #myString# /cfoutput ### DESIRED YIELD ### #102;#111;o#64;#98;a#114;#46;c#111;#109; hello #106;#105;m#64;#106;a#109;#46;c#111;#109; goodbye Thanks, Jamie [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Rereplace with regular expression not working as I had hoped.
You need to 'remember' the character grabbed by the dot in a backreference: rereplace(string, (.)/(.), \1 / \2, all); That should take care of you.If you have any more questions, we might want to move to CF-Regex (available via the HoF archives if you don't want to subscribe). --Ben Doom DURETTE, STEVEN J (AIT) wrote: Hi all, Here is a quick one for you. I have a Variable that I am trying to do a rereplace on and it isn't working as I expected. Here is the code: cfset Variables.myNewVar = rereplace(Variables.myOldVar,./., . / ., All) I was hoping that it would convert: DOGS/CATS TO: DOGS / CATS but it returns: DOG. / .ATS I also tried it with the replacement string being / and got: DOG / ATS Can anyone tell me what I need to do to get it to DOGS / CATS Thanks, Steve -- COST SAVINGS SUGGESTION* For pages that must be printed, change your print settings to print in grayscale instead of color. Steve Durette Mgr-Eng. Const. Systems Support (586)466-7654 [OFFICE] 100 S. Main Room 314 Mt. Clemens, MI 48043 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Rereplace with regular expression not working as I had hoped.
You need to grab the S from DOGS and the C from Cats that you are replacing. For example: cfset Variables.myNewVar = rereplace(Variables.myOldVar,(.)/(.), .\1/\2.,All) the () around the dots grabs those values. The \1 and \2 put them back in. Does that make sense? Jerry Johnson [EMAIL PROTECTED] 01/09/04 02:05PM Hi all, Here is a quick one for you. I have a Variable that I am trying to do a rereplace on and it isn't working as I expected. Here is the code: cfset Variables.myNewVar = rereplace(Variables.myOldVar,./., . / ., All) I was hoping that it would convert: DOGS/CATS TO: DOGS / CATS but it returns: DOG. / .ATS I also tried it with the replacement string being / and got: DOG / ATS Can anyone tell me what I need to do to get it to DOGS / CATS Thanks, Steve -- COST SAVINGS SUGGESTION* For pages that must be printed, change your print settings to print in grayscale instead of color. Steve Durette Mgr-Eng. Const. Systems Support (586)466-7654 [OFFICE] 100 S. Main Room 314 Mt. Clemens, MI 48043 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: REReplace not working as it should ... or is it me? -- REWRITTEN
If you search the cf-regex archives, they're full of stuff like this. It's a common problem. What you are seeing (I suspect) is the regex grabbing everything from the div id=whatever to the last /div. This is because regex, by default, uses greedy matching. In CFMX, you can do a non-greedy match like so: div id=newsletterBody(.*?)/div In CF5, the easy shortcut is to turn the /divs into something untypable -- I like the bell symbol for no real reason. bell = chr(7) So, string = replacenocase(string, /div, #chr(7)#, all); string = rereplacenocase(string, div id=whatever([^#chr(7)#]*)#chr(7)#, whatever); If you want to discuss this more in depth, I suggest we shlep on over to http://www.houseoffusion.com/cf_lists/index.cfm?method=threadsforumid=21 where we can discuss this on-topic, in depth, and with a good number of very smart regexers. :-) -- Ben Doom Programmer General Lackey Moonbow Software, Inc : -Original Message- : From: mayo [mailto:[EMAIL PROTECTED] : Sent: Saturday, August 02, 2003 4:04 PM : To: CF-Talk : Subject: REReplace not working as it should ... or is it me? -- : REWRITTEN : : : I'm creating a system to allow some users update parts of their site. : : 1. I'm using CFFILE action=read to pull the file. : 2. Then I'm pulling out sections within divs to be replaced. : 3. These sections are placed in forms allowing users to update : them and then : using CFFILE to update the file by writing over the existing file. : : OK, so far so good. The problem is in the regex. It works -- but not as it : should?!? : : cfset title = REreplace(readFile,'^.*div : id=newsletterBody(.*)/div.*$','\1','all') : : I read the regex above as : : Scan through string readFile : : 1. start at the begining ^.* : 2. find div id=newsletterBody(.*)/div : 3. group 1 is everything between the divs : : That DIDN'T WORK !!! OK, what to do? Let's put a stop. Search for : everything : except for a : : 4. Replace (.*) with ([^]*) : This worked fine except for the fact that there are Ps and BRs. : Alrightly then use a @ as the stop. : 5. I replaced ([^]*) with ([EMAIL PROTECTED]) and put a @ between the divs. That : didn't work!!! : 6. After much fumbling I put the @ after the divs. That worked. : Go figure? : : QUESTION: : : Isn't group 1 ([EMAIL PROTECTED]) between the divs. Why would the @ work outside : the divs? : : : I have : div id=newsletterBody : lorem ipsum whateverP : lorem ipsum moreP : stuffP : /div!-- @ -- : : Thanks for any insight. : : Gilbert Midonnet : : : : : : : : ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: REReplace and Replace function
reReplace = replaces based on a RE (Regular Expression) and Replace = replaces based on a string literal? or string? ...tony Tony Weeg Senior Web Developer UnCertified Advanced ColdFusion Developer Information System Design Navtrak, Inc. Mobile workforce monitoring, mapping reporting www.navtrak.net 410.548.2337 -Original Message- From: Tuan [mailto:[EMAIL PROTECTED]] Sent: Friday, February 14, 2003 2:39 PM To: CF-Talk Subject: REReplace and Replace function Can somebody explain what the difference is between the REReplace and Replace function? Im confused when to use one or the other and their differences. ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace and Replace function
Tuan writes: Can somebody explain what the difference is between the REReplace and Replace function? Im confused when to use one or the other and their differences. replace() is a simple function to replace one character (or string of characters) with another. for example, in the string the quick brown fox jumped over the lazy dog, you could replace the word 'fox' with 'goldfish' by doing: cfset mystring = the quick brown fox jumped over the lazy dog cfset myNewString = replace(myString, fox, goldfish, all) reReplace() uses regular expressions (pattern matching) to determine what item/string/characters to replace. Instead of specifying a particular string/character to be replaced, you can specify a pattern (for example, the word 'foo' only if it's the last word in a sentence). I unfortunately still haven't fulfilled my ambition of learning regular expressions...but I'm sure that Ben Doom, the cf-talk RegExp Ninja (tm) will be happy to elaborate there :) Charlie ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: REReplace and Replace function
From: Tuan [mailto:[EMAIL PROTECTED]] Can somebody explain what the difference is between the REReplace and Replace function? Im confused when to use one or the other and their differences. Here's an example. cfset myString=a1b2c3d4e5f6g7h8i9j0 If I wanted to remove the number 1 from this string, that's simply Replace(myString,1,,ALL) But if I wanted to remove all the numbers, I'd have to do Replace(myString,1,,ALL) Replace(myString,2,,ALL) Replace(myString,3,,ALL) Replace(myString,4,,ALL) Replace(myString,5,,ALL) Replace(myString,6,,ALL) Replace(myString,7,,ALL) Replace(myString,8,,ALL) Replace(myString,9,,ALL) Replace(myString,0,,ALL) Or REReplace(myString,[^0-9],,ALL) Regular Expressions can be quite powerful, and I've only scratched the surface. The syntax can be hard to grok, though. (I don't pretend to be anything but a Regular Expression amateur.) ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: REReplace and Replace function
Replace() looks for a literal string within another string and replaces it with yet a third string: Replace(contentstring, stringtoreplace, replacement); With REReplace(), you can search for and replace with regular expressions. This makes the function much more powerful and often more useful, but at the expense of overhead. For simple replaces, use the simple replace() :-) If you want to know more about regular expressions, House of Fusion also hosts the CF-RegEx list, on which several of the CF Regex Ninjas answer questions both simple and advanced. We'd be happy to help you out. http://www.houseoffusion.com/cf_lists/index.cfm?method=threadsforumid=21 -- Ben Doom Programmer General Lackey Moonbow Software, Inc : -Original Message- : From: Tuan [mailto:[EMAIL PROTECTED]] : Sent: Friday, February 14, 2003 2:39 PM : To: CF-Talk : Subject: REReplace and Replace function : : : Can somebody explain what the difference is between the REReplace : and Replace function? Im confused when to use one or the other : and their differences. : : : : : : : ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: REReplace and Replace function
: Regular Expressions can be quite powerful, and I've only scratched the : surface. The syntax can be hard to grok, though. (I don't pretend to be : anything but a Regular Expression amateur.) If you knew the number of times that this particular RENinja learned a new trick from an ameteur who did something completely original -- Ben Doom of the Regex Ninja Clan ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: REReplace and Replace function
This makes the function much more powerful and often more useful, but at the expense of overhead. To what extent? I mean would I be better off using ReReplace(string, a|b|c, , ALL) or Replace(string, a, ) Replace(string, b, ) Replace(string, c, ) Just curious... I use them both ALOT - Original Message - From: Ben Doom [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Friday, February 14, 2003 2:51 PM Subject: RE: REReplace and Replace function Replace() looks for a literal string within another string and replaces it with yet a third string: Replace(contentstring, stringtoreplace, replacement); With REReplace(), you can search for and replace with regular expressions. This makes the function much more powerful and often more useful, but at the expense of overhead. For simple replaces, use the simple replace() :-) If you want to know more about regular expressions, House of Fusion also hosts the CF-RegEx list, on which several of the CF Regex Ninjas answer questions both simple and advanced. We'd be happy to help you out. http://www.houseoffusion.com/cf_lists/index.cfm?method=threadsforumid=21 -- Ben Doom Programmer General Lackey Moonbow Software, Inc : -Original Message- : From: Tuan [mailto:[EMAIL PROTECTED]] : Sent: Friday, February 14, 2003 2:39 PM : To: CF-Talk : Subject: REReplace and Replace function : : : Can somebody explain what the difference is between the REReplace : and Replace function? Im confused when to use one or the other : and their differences. : : : : : : : ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: ReReplace for HTML tags
Russ wrote: Everything works nicely from a display perspective. In order to be safe, secure and prevent anyone from entering junk into our comments--such as unclosed HTML tags or other junk that could break the site, I have set the following: CFSET commentOutput = #Replace(commentPost,strCRLF,strHTMLCRLF,'all')# THEN, because I thought I was wise, I did the following: #ReReplace(commentOutput,[^]*, ,all)# This is an attempt to strip out any HTML that anyone ELSE might but in, failing to realize that I'd just stripped out my own HTML that I wanted to place in there. I am taking a guess that I'd have to get rid of the all in my ReReplace, but I'm not entirely sure how that'd work nor am I sure that's the right path. Can anyone offer any insight? Switch the order. First strip ALL HTML (it is theirs), then add your own. Jochem ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: ReReplace for HTML tags
Switch the order. First strip ALL HTML (it is theirs), then add your own. Gah! Thanks; I don't know why it didn't occur to me to do it that way. Extra set of eyes, indeed! Peace. ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: ReReplace for HTML tags
I don't know if it'll help in your situation, but I've done a BBML parser in CF that might solve some of your problems: http://www.depressedpress.com/DepressedPress/Content/ColdFusion/CustomTa gs/DP_ParseBBML/Index.cfm The basic idea is that users are allowed a simplified version of HTML, BBML (actually an HTML-like mark up). With it they can do most formatting (bold, lists, links, images), but nothing else (script, tables, etc). In effect it lets you offer some presentation control without risk the general layout of the site. Jim Davis -Original Message- From: Russ [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 05, 2003 7:41 PM To: CF-Talk Subject: ReReplace for HTML tags All... I'm attempting to combine a few options--and I'm realizing that it's not working out as well as I'd hoped, but for obvious reasons. Hopefully, someone will know what I'm attempting to do and guide me to the light a little bit. Users make comments to a blog--when they make those comments, they are entered into the database. When we view the comments, we have set some variables so the carriage returns are placed accordingly, by doing: CFSET strCRLF = #Chr(10)# #Chr(13)# CFSET strHTMLCRLF = P/ When we apply those variables to the comment of the blog: #Replace(blogContent,strCRLF,strHTMLCRLF,'all')# Everything works nicely from a display perspective. In order to be safe, secure and prevent anyone from entering junk into our comments--such as unclosed HTML tags or other junk that could break the site, I have set the following: CFSET commentOutput = #Replace(commentPost,strCRLF,strHTMLCRLF,'all')# THEN, because I thought I was wise, I did the following: #ReReplace(commentOutput,[^]*, ,all)# This is an attempt to strip out any HTML that anyone ELSE might but in, failing to realize that I'd just stripped out my own HTML that I wanted to place in there. I am taking a guess that I'd have to get rid of the all in my ReReplace, but I'm not entirely sure how that'd work nor am I sure that's the right path. Can anyone offer any insight? Thanks! Russ Unger Managing Partner blueChrome design, LLC www.bluechromedesign.com 312.593.4260 :office 877.433.8427 :pager 312.873.4033 :fax Yep, we're hosting CFMX and MySQL. Email for info. ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: RE: ReReplace for HTML tags
htmlEditFormat htmlEditFormat. htmlEditFormat... Am I the only person in the whole world that uses this function? - Original Message - From: Russ [EMAIL PROTECTED] Date: Wednesday, February 5, 2003 5:57 pm Subject: RE: ReReplace for HTML tags Switch the order. First strip ALL HTML (it is theirs), then add your own. Gah! Thanks; I don't know why it didn't occur to me to do it that way. Extraset of eyes, indeed! Peace. ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: RE: ReReplace for HTML tags
HEHE :) Pablo - Original Message - From: [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Wednesday, February 05, 2003 7:01 PM Subject: Re: RE: ReReplace for HTML tags htmlEditFormat htmlEditFormat. htmlEditFormat... Am I the only person in the whole world that uses this function? - Original Message - From: Russ [EMAIL PROTECTED] Date: Wednesday, February 5, 2003 5:57 pm Subject: RE: ReReplace for HTML tags Switch the order. First strip ALL HTML (it is theirs), then add your own. Gah! Thanks; I don't know why it didn't occur to me to do it that way. Extraset of eyes, indeed! Peace. ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: ReReplace for HTML tags
Sounds a lot like what I was contemplating tackling next, either that or reinventing something else I've done before in .asp, but... Well, your page doesn't seem to work. -Original Message- From: Jim Davis [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 05, 2003 6:59 PM To: CF-Talk Subject: RE: ReReplace for HTML tags I don't know if it'll help in your situation, but I've done a BBML parser in CF that might solve some of your problems: http://www.depressedpress.com/DepressedPress/Content/ColdFusio n/CustomTa gs/DP_ParseBBML/Index.cfm The basic idea is that users are allowed a simplified version of HTML, BBML (actually an HTML-like mark up). With it they can do most formatting (bold, lists, links, images), but nothing else (script, tables, etc). In effect it lets you offer some presentation control without risk the general layout of the site. Jim Davis ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: ReReplace for HTML tags
-Original Message- From: Russ [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 05, 2003 8:08 PM To: CF-Talk Subject: RE: ReReplace for HTML tags Sounds a lot like what I was contemplating tackling next, either that or reinventing something else I've done before in .asp, but... I still haven't actually used it for anything... It started as a weekend lark and grew. (I had planned on a BLOG system, but never got around to it.) I think it's pretty feature rich and suprisingly quick (it ain't fast, but it's peppy). It's unencrypted so feel free to dig through it. Well, your page doesn't seem to work. It's working now at least - are you sure you got the whole URL? It's quite long, impressive and manly you know. ;^) You've got to get all the way to the index.cfm: http://www.depressedpress.com/DepressedPress/Content/ColdFusion/CustomTa gs/DP_ParseBBML/Index.cfm If the site just isn't working for you I'd be happy to send you a copy of the tag (the full package is 100kb - but a lot of that is docs and smiley graphics). Jim Davis ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: REReplace
Double check your spelling. Rick -Original Message- From: FlashGuy [mailto:[EMAIL PROTECTED]] Sent: Monday, December 16, 2002 11:29 AM To: CF-Talk Subject: REReplace For some reason I can't to a replace on the following: dir = D:\\ cfset test = #RERplace(dir,\\,\,ALL)# --- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba --- ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com
RE: REReplace
It might be the \ escaping itself. Try Replace() instead. Ade -Original Message- From: FlashGuy [mailto:[EMAIL PROTECTED]] Sent: 16 December 2002 17:29 To: CF-Talk Subject: REReplace For some reason I can't to a replace on the following: dir = D:\\ cfset test = #RERplace(dir,\\,\,ALL)# --- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba --- ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.
Re: REReplace
I am sure there is a better way, however the \ is part of the ReReplace command for RegularExpressions. Try: cfset dir=D:\\ cfset slash_counter = #FindNoCase(\\,dir,1)# CFLOOP condition=slash_counter NEQ 0 cfset dir=#Replace(dir,\\,\,All)# cfset slash_counter = #FindNoCase(\\,dir,1)# /CFLOOP [EMAIL PROTECTED] 12/16/02 12:29PM For some reason I can't to a replace on the following: dir = D:\\ cfset test = #RERplace(dir,\\,\,ALL)# --- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba --- ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com
Re: REReplace
Nevermind... On Mon, 16 Dec 2002 12:29:23 -0500, FlashGuy wrote: For some reason I can't to a replace on the following: dir = D:\\ cfset test = #RERplace(dir,\\,\,ALL)# --- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba --- --- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba --- ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm
RE: REReplace
cfset test = #REReplace(dir,\\,\,ALL)# -Original Message- From: FlashGuy [mailto:[EMAIL PROTECTED]] Sent: Monday, December 16, 2002 12:29 PM To: CF-Talk Subject: REReplace For some reason I can't to a replace on the following: dir = D:\\ cfset test = #RERplace(dir,\\,\,ALL)# --- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba --- ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com
Re: REReplace
\ is a special character, so you have to escape it cfset test = #REReplace(dir,,\\,ALL)# But in this case you're better off just using replace: cfset test = #Replace(dir,\\,\,ALL)# At 12:29 PM 12/16/2002, you wrote: For some reason I can't to a replace on the following: dir = D:\\ cfset test = #RERplace(dir,\\,\,ALL)# ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com
RE: REReplace and RegExp
Someone will have to submit it. Considering Rob and I are already _swamped_ under the queue now, it would be better if someone were to submit this. I just can't bring myself to make the queue bigger. I'll let others do that. ;) Just as an FYI - both Rob and I know the queue is getting a bit backed up now. Rob is very busy, and I've been working on a little product you may have heard of. (It's does dynamic web page crap. ;) Once things settle down, the queue will get busted down. Plus, we have some interesting things in work for the site as well as a new site. === Raymond Camden, Principal Spectra Compliance Engineer for Macromedia Email: [EMAIL PROTECTED] Yahoo IM : morpheus My ally is the Force, and a powerful ally it is. - Yoda -Original Message- From: James Ang [mailto:[EMAIL PROTECTED]] Sent: Monday, April 22, 2002 6:11 PM To: CF-Talk Subject: RE: REReplace and RegExp Actually, this looks like a UDF candidate for cflib.org. Ray Camden? I don't have time to format it nicely for cflib.org. Anyone wants to volunteer? :) // Assuming that strFind and strReplace has no RegExp characters that need to be escaped // else, someone has to make this UDF more robust! ;) function SwapTag(strSource, strFind, strReplace) { var retVal = strSource; // make sure that the substring to find is not empty. if (Len(Trim(strFind))) { retVal = REFindNoCase(strSource, (/?)#strFind#([[:space:]]*|[[:space:]]+[^]*), \1#strReplace#\2, ALL); } return retVal; } __ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: REReplace and RegExp
James, Thanks for the response. It has given me other ideas about how to approach this. It appears that the solution you provided only replaces that Tags, which is part of the desired solution. I also need to obtain the value of the attributes and put then in differenct attributes for the a tag. The real kicker is that the attributes in the agent tag can be in any order. For example: From this: agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure,b.1929/agent agent aid=2481 acutter=B847 primary=NOBruggen, Coosje van, b.1942/agent To this: a href=results.cfm?c=aidq=157Oldenburg, Claes Thure, b.1929/a a href=results.cfm?c=aidq=2481Bruggen, Coosje van, b.1942/a So far, I've come up with this, which is not complete: REReplaceNoCase( agentList, 'agent[[:space:]]+primary=(YES|NO)[[:space:]]+aid=([0-9]*)[[:space:]]+a cutter=([a-z0-9]*)(.[^]*?)/agent', 'a href=results.cfm?c=aidq=\2\4/a', ALL) Background: I am using ColdFusion 4.51 on a Windows2000/IIS5 server. The agent tags come from an XML document that looks like this: ?xml version=1.0? citation accno60793/accno titleParc Andre-Citroen/title settitle sid=929Paris: Parks and Gardens, 1615-1992/settitle callnumberlGxFR B343a A53ed05/callnumber agents agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure, b.1929/agent agent aid=2481 primary=NO acutter=B847Bruggen, Coosje van, b.1942/agent agent primary=YES aid=9387 acutter=B343Berger, Patrick, b. 1947/agent agent primary=NO aid=9388 acutter=V668Viguier, Jean-Paul/agent agent acutter=J474 primary=NO aid=9389Jodry, Jean-Francois/agent agent primary=NO aid=9390 acutter=C585Clement, Gilles/agent agent primary=NO aid=9391Provost, Alain/agent /agents /citation Thanks, Troy -- Troy Simpson Applications Analyst/Programmer - MCSE, OCP DBA North Carolina State University Libraries Campus Box 7111 | Raleigh | North Carolina ph.919.515.3855 | fax.919.513.3330 [EMAIL PROTECTED] -Original Message- From: James Ang [mailto:[EMAIL PROTECTED]] Sent: Monday, April 22, 2002 5:45 PM To: CF-Talk Subject: RE: REReplace and RegExp Try this: REReplaceNoCase(agents, (/?)agent([[:space:]]*|[[:space:]]+[^]*), \1a\2, ALL) I have tested this code on CFAS 5 on WinXP. James Ang Senior Programmer MedSeek, Inc. -Original Message- From: Troy Simpson [mailto:[EMAIL PROTECTED]] Sent: Monday, April 22, 2002 2:15 PM To: CF-Talk Subject: REReplace and RegExp Dear CF-Talkers: I have a string in the following format( I've added carriage returns for readability): cfset agents = 'agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure, b.1929/agent' 'agent primary=NO aid=2481 acutter=B847Bruggen, Coosje van, b.1942/agent' 'agent primary=YES aid=9387 acutter=B343Berger, Patrick, b. 1947/agent' I want to process the string to look like this (replace the AGENT tags with ANCHOR tags): cfset agents = 'a href=results.cfm?c=aidq=157Oldenburg, Claes Thure, b.1929/a' 'a href=results.cfm?c=aidq=2481Bruggen, Coosje van, b.1942/a' 'a href=reulsts.cfm?c=aidq=9387Berger, Patrick, b. 1947/a' I have somewhat accomplished this like so but still need some work and have become a little lost. REReplaceNoCase( agent, 'agent[[:space:]]+primary=(YES|NO)[[:space:]]+aid=([0-9]*)[[:space: ]]+a cutter=([a-z0-9]*)(.*)?/agent', ' a href=results.cfm?c=aidq=\2\4/a ', ALL) **Another problem is that the AGENT Attributes can be in any order which really throughs wrench into things. Anyone have any advise on how to approach this? I would really appreciated it. Thanks, Troy -- Troy Simpson Applications Analyst/Programmer - MCSE, OCP-DBA North Carolina State University Libraries Campus Box 7111 | Raleigh | North Carolina ph.919.515.3855 | fax.919.513.3330 [EMAIL PROTECTED] __ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: REReplace and RegExp
Troy, What you need is a 2-part parser. There isn't an easy way unless you decide to use MS XML Parser or the Apache.org Java parser to parse the XML. If you decided not to use the Apache or the MS XML parsers, here's how your tag parser would do: Step 1: Retrieve a start tag one at a time: agent([[:space:]]*|[[:space:]]+[^]*) Step 2: Retrieve the individual attributes of the tag retrieved in step 1 Step 3: Perform transformation of the attributes in step 2. Step 4: Perform transformation of the tag in Step 1 Step 5: Place the transformed string back in to xml input stream OR place the transformed stream into your output stream. Step 6: If not end of file/stream, go to Step 1. Attached is a sample code that might help. It is meant for CFAS 5. I wrote it thinking that it would solve your problem until I re-read your posting. :P The attached file should provide some insight, I hope. :) For the code to work in CFAS 4.5.x, you will need to convert the UDF to Custom Tags. Good luck. :) Back to *real* work. (This list is too much fun.) James Ang Senior Programmer MedSeek, Inc. [EMAIL PROTECTED] - Original Message - From: Troy Simpson [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, April 23, 2002 8:04 AM Subject: RE: REReplace and RegExp James, Thanks for the response. It has given me other ideas about how to approach this. It appears that the solution you provided only replaces that Tags, which is part of the desired solution. I also need to obtain the value of the attributes and put then in differenct attributes for the a tag. The real kicker is that the attributes in the agent tag can be in any order. For example: From this: agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure,b.1929/agent agent aid=2481 acutter=B847 primary=NOBruggen, Coosje van, b.1942/agent To this: a href=results.cfm?c=aidq=157Oldenburg, Claes Thure, b.1929/a a href=results.cfm?c=aidq=2481Bruggen, Coosje van, b.1942/a So far, I've come up with this, which is not complete: REReplaceNoCase( agentList, 'agent[[:space:]]+primary=(YES|NO)[[:space:]]+aid=([0-9]*)[[:space: ]]+a cutter=([a-z0-9]*)(.[^]*?)/agent', 'a href=results.cfm?c=aidq=\2\4/a', ALL) Background: I am using ColdFusion 4.51 on a Windows2000/IIS5 server. The agent tags come from an XML document that looks like this: ?xml version=1.0? citation accno60793/accno titleParc Andre-Citroen/title settitle sid=929Paris: Parks and Gardens, 1615-1992/settitle callnumberlGxFR B343a A53ed05/callnumber agents agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure, b.1929/agent agent aid=2481 primary=NO acutter=B847Bruggen, Coosje van, b.1942/agent agent primary=YES aid=9387 acutter=B343Berger, Patrick, b. 1947/agent agent primary=NO aid=9388 acutter=V668Viguier, Jean-Paul/agent agent acutter=J474 primary=NO aid=9389Jodry, Jean-Francois/agent agent primary=NO aid=9390 acutter=C585Clement, Gilles/agent agent primary=NO aid=9391Provost, Alain/agent /agents /citation Thanks, Troy -- Troy Simpson Applications Analyst/Programmer - MCSE, OCP DBA North Carolina State University Libraries Campus Box 7111 | Raleigh | North Carolina ph.919.515.3855 | fax.919.513.3330 [EMAIL PROTECTED] -Original Message- From: James Ang [mailto:[EMAIL PROTECTED]] Sent: Monday, April 22, 2002 5:45 PM To: CF-Talk Subject: RE: REReplace and RegExp Try this: REReplaceNoCase(agents, (/?)agent([[:space:]]*|[[:space:]]+[^]*), \1a\2, ALL) I have tested this code on CFAS 5 on WinXP. James Ang Senior Programmer MedSeek, Inc. -Original Message- From: Troy Simpson [mailto:[EMAIL PROTECTED]] Sent: Monday, April 22, 2002 2:15 PM To: CF-Talk Subject: REReplace and RegExp Dear CF-Talkers: I have a string in the following format( I've added carriage returns for readability): cfset agents = 'agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure, b.1929/agent' 'agent primary=NO aid=2481 acutter=B847Bruggen, Coosje van, b.1942/agent' 'agent primary=YES aid=9387 acutter=B343Berger, Patrick, b. 1947/agent' I want to process the string to look like this (replace the AGENT tags with ANCHOR tags): cfset agents = 'a href=results.cfm?c=aidq=157Oldenburg, Claes Thure, b.1929/a' 'a href=results.cfm?c=aidq=2481Bruggen, Coosje van, b.1942/a' 'a href=reulsts.cfm?c=aidq=9387Berger, Patrick, b. 1947/a' I have somewhat accomplished this like so but still need some work and have become a little lost. REReplaceNoCase( agent, 'agent[[:space:]]+primary=(YES|NO)[[:space:]]+aid=([0-9]*)[[:space: ]]+a cutter=([a-z0-9]*)(.*)?/agent', ' a href=results.cfm?c=aidq=\2\4/a ', ALL) **Another problem is that the AGENT Attributes can be in any order which really throughs wrench into things. Anyone have any advise on how to approach this? I would really appreciated it. Thanks, Troy -- Troy Simpson Applications Analyst/Programmer
RE: REReplace and RegExp
James, Thanks again. Great food for thought. Is there a performance hit with either of the XML Parsers you suggested? If so, what has been your experience? Do these XML Parsers use something called XPath to get the data from the XML Document? Background: I have created a pre-joined resultset of all the records(CITATION) and stored them in an Oracle9i Table (a.k.a Materialize View). This basically takes all the records and joins them together into a denormalized spreadsheet to elliminate the expensive joins at runtime. One of the columns in my Table contains an XML Document compiled from all the tables and columns used for TEXT indexing and searching. Like I said, the documents are stored in an Oracle9i database table column as an XML document of type XMLType (clob or Character Large Object). There is some functionality in the database to parse the XML Document but as of now, I do not know how elaborate or expansive these functions are. Ideally, I am trying to make the Oracle9i Database do the work for me before returning the result set to the ColdFusion Application Server for processing. So far I've been able to get a list of agent tags for all my agents in a Citation. I wonder if the XML functionality in the Oracle9i database exist and is as good as that of the two parsers you suggested? I also have the option to store the values in seperate columns. The problem I am running into is that mutliple agents can exist for each CITATION and I only want one record in the table(a.k.a Materialized View) for each CITATION. XML Document -- ?xml version=1.0? citation accno60793/accno titleParc Andre-Citroen/title settitle sid=929Paris: Parks and Gardens, 1615-1992/settitle callnumberlGxFR B343a A53ed05/callnumber agents agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure, b.1929/agent agent aid=2481 primary=NO acutter=B847Bruggen, Coosje van, b.1942/agent agent primary=YES aid=9387 acutter=B343Berger, Patrick, b. 1947/agent agent primary=NO aid=9388 acutter=V668Viguier, Jean-Paul/agent agent acutter=J474 primary=NO aid=9389Jodry, Jean-Francois/agent agent primary=NO aid=9390 acutter=C585Clement, Gilles/agent agent primary=NO aid=9391Provost, Alain/agent /agents /citation - Thanks Troy -- Troy Simpson Applications Analyst/Programmer - MCSE, OCP DBA North Carolina State University Libraries Campus Box 7111 | Raleigh | North Carolina ph.919.515.3855 | fax.919.513.3330 [EMAIL PROTECTED] -Original Message- From: James Ang [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 1:14 PM To: CF-Talk Subject: Re: REReplace and RegExp Troy, What you need is a 2-part parser. There isn't an easy way unless you decide to use MS XML Parser or the Apache.org Java parser to parse the XML. If you decided not to use the Apache or the MS XML parsers, here's how your tag parser would do: Step 1: Retrieve a start tag one at a time: agent([[:space:]]*|[[:space:]]+[^]*) Step 2: Retrieve the individual attributes of the tag retrieved in step 1 Step 3: Perform transformation of the attributes in step 2. Step 4: Perform transformation of the tag in Step 1 Step 5: Place the transformed string back in to xml input stream OR place the transformed stream into your output stream. Step 6: If not end of file/stream, go to Step 1. Attached is a sample code that might help. It is meant for CFAS 5. I wrote it thinking that it would solve your problem until I re-read your posting. :P The attached file should provide some insight, I hope. :) For the code to work in CFAS 4.5.x, you will need to convert the UDF to Custom Tags. Good luck. :) Back to *real* work. (This list is too much fun.) James Ang Senior Programmer MedSeek, Inc. [EMAIL PROTECTED] - Original Message - From: Troy Simpson [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, April 23, 2002 8:04 AM Subject: RE: REReplace and RegExp James, Thanks for the response. It has given me other ideas about how to approach this. It appears that the solution you provided only replaces that Tags, which is part of the desired solution. I also need to obtain the value of the attributes and put then in differenct attributes for the a tag. The real kicker is that the attributes in the agent tag can be in any order. For example: From this: agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure,b.1929/agent agent aid=2481 acutter=B847 primary=NOBruggen, Coosje van, b.1942/agent To this: a href=results.cfm?c=aidq=157Oldenburg, Claes Thure, b.1929/a a href=results.cfm?c=aidq=2481Bruggen, Coosje van, b.1942/a So far, I've come up with this, which is not complete: REReplaceNoCase( agentList, 'agent[[:space:]]+primary=(YES|NO)[[:space:]]+aid=([0-9]*)[[:space: ]]+a cutter=([a-z0-9]*)(.[^]*?)/agent', 'a href=results.cfm?c=aidq=\2\4/a', ALL) Background: I am using ColdFusion
RE: REReplace and RegExp
Here are the URL to the mentioned parsers: Java-based (AND C++,Perl,COM) for the Anti-MS camp: http://xml.apache.org/ Strictly COM-based for the those following the Dark M$ path: http://www.microsoft.com/xml/ The Apache XML Xalan Project supports Xpath in its latest iteration. MS XML 4.0 supports Xpath. Both of these implementations are pretty big and can have a performance hit at script/runtime. In my opinion, they would not scale properly if it is used on a page that gets hit a lot. Both implementations have memory leak issues on certain configurations (I have seen an early Apache parser dies after parsing and transforming 10,000 to 50,000 documents for a particular JVM that I can't remember off the top of my head). The MS XML stuff is notorious for memory leaks for certain pattern of usage. I am sure it has been reduced/eliminated with the latest iteration. I think you may have to batch the processing and store it somewhere. Have the batch run every so often to refresh the data. I doubt the Oracle dudes would do better than the Apache or the Microsoft XML teams. These two implementations are the best out there. I would not be surprised if Oracle used or incorporated a portion of the Apache parser. Good luck! :) James Ang Senior Programmer MedSeek, Inc. [EMAIL PROTECTED] -Original Message- From: Troy Simpson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 11:07 AM To: CF-Talk Subject: RE: REReplace and RegExp James, Thanks again. Great food for thought. Is there a performance hit with either of the XML Parsers you suggested? If so, what has been your experience? Do these XML Parsers use something called XPath to get the data from the XML Document? Background: I have created a pre-joined resultset of all the records(CITATION) and stored them in an Oracle9i Table (a.k.a Materialize View). This basically takes all the records and joins them together into a denormalized spreadsheet to elliminate the expensive joins at runtime. One of the columns in my Table contains an XML Document compiled from all the tables and columns used for TEXT indexing and searching. Like I said, the documents are stored in an Oracle9i database table column as an XML document of type XMLType (clob or Character Large Object). There is some functionality in the database to parse the XML Document but as of now, I do not know how elaborate or expansive these functions are. Ideally, I am trying to make the Oracle9i Database do the work for me before returning the result set to the ColdFusion Application Server for processing. So far I've been able to get a list of agent tags for all my agents in a Citation. I wonder if the XML functionality in the Oracle9i database exist and is as good as that of the two parsers you suggested? I also have the option to store the values in seperate columns. The problem I am running into is that mutliple agents can exist for each CITATION and I only want one record in the table(a.k.a Materialized View) for each CITATION. XML Document -- ?xml version=1.0? citation accno60793/accno titleParc Andre-Citroen/title settitle sid=929Paris: Parks and Gardens, 1615-1992/settitle callnumberlGxFR B343a A53ed05/callnumber agents agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure, b.1929/agent agent aid=2481 primary=NO acutter=B847Bruggen, Coosje van, b.1942/agent agent primary=YES aid=9387 acutter=B343Berger, Patrick, b. 1947/agent agent primary=NO aid=9388 acutter=V668Viguier, Jean-Paul/agent agent acutter=J474 primary=NO aid=9389Jodry, Jean-Francois/agent agent primary=NO aid=9390 acutter=C585Clement, Gilles/agent agent primary=NO aid=9391Provost, Alain/agent /agents /citation - Thanks Troy -- Troy Simpson Applications Analyst/Programmer - MCSE, OCP DBA North Carolina State University Libraries Campus Box 7111 | Raleigh | North Carolina ph.919.515.3855 | fax.919.513.3330 [EMAIL PROTECTED] -Original Message- From: James Ang [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 1:14 PM To: CF-Talk Subject: Re: REReplace and RegExp Troy, What you need is a 2-part parser. There isn't an easy way unless you decide to use MS XML Parser or the Apache.org Java parser to parse the XML. If you decided not to use the Apache or the MS XML parsers, here's how your tag parser would do: Step 1: Retrieve a start tag one at a time: agent([[:space:]]*|[[:space:]]+[^]*) Step 2: Retrieve the individual attributes of the tag retrieved in step 1 Step 3: Perform transformation of the attributes in step 2. Step 4: Perform transformation of the tag in Step 1 Step 5: Place the transformed string back in to xml input stream OR place the transformed stream into your output stream. Step 6: If not end of file/stream, go to Step 1. Attached is a sample code that might help. It is meant
RE: REReplace and RegExp
Try this: REReplaceNoCase(agents, (/?)agent([[:space:]]*|[[:space:]]+[^]*), \1a\2, ALL) I have tested this code on CFAS 5 on WinXP. James Ang Senior Programmer MedSeek, Inc. -Original Message- From: Troy Simpson [mailto:[EMAIL PROTECTED]] Sent: Monday, April 22, 2002 2:15 PM To: CF-Talk Subject: REReplace and RegExp Dear CF-Talkers: I have a string in the following format( I've added carriage returns for readability): cfset agents = 'agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure, b.1929/agent' 'agent primary=NO aid=2481 acutter=B847Bruggen, Coosje van, b.1942/agent' 'agent primary=YES aid=9387 acutter=B343Berger, Patrick, b. 1947/agent' I want to process the string to look like this (replace the AGENT tags with ANCHOR tags): cfset agents = 'a href=results.cfm?c=aidq=157Oldenburg, Claes Thure, b.1929/a' 'a href=results.cfm?c=aidq=2481Bruggen, Coosje van, b.1942/a' 'a href=reulsts.cfm?c=aidq=9387Berger, Patrick, b. 1947/a' I have somewhat accomplished this like so but still need some work and have become a little lost. REReplaceNoCase( agent, 'agent[[:space:]]+primary=(YES|NO)[[:space:]]+aid=([0-9]*)[[:space: ]]+a cutter=([a-z0-9]*)(.*)?/agent', ' a href=results.cfm?c=aidq=\2\4/a ', ALL) **Another problem is that the AGENT Attributes can be in any order which really throughs wrench into things. Anyone have any advise on how to approach this? I would really appreciated it. Thanks, Troy -- Troy Simpson Applications Analyst/Programmer - MCSE, OCP-DBA North Carolina State University Libraries Campus Box 7111 | Raleigh | North Carolina ph.919.515.3855 | fax.919.513.3330 [EMAIL PROTECTED] __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: REReplace and RegExp
Actually, this looks like a UDF candidate for cflib.org. Ray Camden? I don't have time to format it nicely for cflib.org. Anyone wants to volunteer? :) // Assuming that strFind and strReplace has no RegExp characters that need to be escaped // else, someone has to make this UDF more robust! ;) function SwapTag(strSource, strFind, strReplace) { var retVal = strSource; // make sure that the substring to find is not empty. if (Len(Trim(strFind))) { retVal = REFindNoCase(strSource, (/?)#strFind#([[:space:]]*|[[:space:]]+[^]*), \1#strReplace#\2, ALL); } return retVal; } James Ang Senior Programmer MedSeek, Inc. [EMAIL PROTECTED] -Original Message- From: James Ang Sent: Monday, April 22, 2002 2:45 PM To: CF-Talk Subject: RE: REReplace and RegExp Try this: REReplaceNoCase(agents, (/?)agent([[:space:]]*|[[:space:]]+[^]*), \1a\2, ALL) I have tested this code on CFAS 5 on WinXP. James Ang Senior Programmer MedSeek, Inc. -Original Message- From: Troy Simpson [mailto:[EMAIL PROTECTED]] Sent: Monday, April 22, 2002 2:15 PM To: CF-Talk Subject: REReplace and RegExp Dear CF-Talkers: I have a string in the following format( I've added carriage returns for readability): cfset agents = 'agent primary=NO aid=157 acutter=O469Oldenburg, Claes Thure, b.1929/agent' 'agent primary=NO aid=2481 acutter=B847Bruggen, Coosje van, b.1942/agent' 'agent primary=YES aid=9387 acutter=B343Berger, Patrick, b. 1947/agent' I want to process the string to look like this (replace the AGENT tags with ANCHOR tags): cfset agents = 'a href=results.cfm?c=aidq=157Oldenburg, Claes Thure, b.1929/a' 'a href=results.cfm?c=aidq=2481Bruggen, Coosje van, b.1942/a' 'a href=reulsts.cfm?c=aidq=9387Berger, Patrick, b. 1947/a' I have somewhat accomplished this like so but still need some work and have become a little lost. REReplaceNoCase( agent, 'agent[[:space:]]+primary=(YES|NO)[[:space:]]+aid=([0-9]*)[[:space: ]]+a cutter=([a-z0-9]*)(.*)?/agent', ' a href=results.cfm?c=aidq=\2\4/a ', ALL) **Another problem is that the AGENT Attributes can be in any order which really throughs wrench into things. Anyone have any advise on how to approach this? I would really appreciated it. Thanks, Troy -- Troy Simpson Applications Analyst/Programmer - MCSE, OCP-DBA North Carolina State University Libraries Campus Box 7111 | Raleigh | North Carolina ph.919.515.3855 | fax.919.513.3330 [EMAIL PROTECTED] __ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: ReReplace(NoCase) maximum length
Perhaps your hitting this: From the CFDOCS: In CFML regular expression functions, large input strings (greater than approximately 20,000 characters) cause a debug assertion failure and a regular expression error occurs. To avoid this, break your input into smaller chunks, as the following example shows. Here the variable input has a size greater than 5. === Raymond Camden, Principal Spectra Compliance Engineer for Macromedia Email: [EMAIL PROTECTED] Yahoo IM : morpheus My ally is the Force, and a powerful ally it is. - Yoda -Original Message- From: James Sleeman [mailto:[EMAIL PROTECTED]] Sent: Friday, February 01, 2002 12:30 AM To: CF-Talk Subject: ReReplace(NoCase) maximum length Hi All, anybody know if there is a maximum length on the string passed to ReReplace(NoCase) ? Reason I ask is that I am running the following ReReplaceNoCase(trim(text), ^HTML(.*)/HTML$, \1); and when the string in text is above a certain length (don't know how long exactly) the code fails with an Invalid regular expression message. I cut the offending text in half (it's comign from a database field (the data in the field is fine, all there, all returned in query)) and each half goes through just fine, but put em togethor and I get the error. Hopefully the designers won't mind me splitting thier page into two (stupidly long anyway) :-) --- James Sleeman __ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
Re: ReReplace(NoCase) maximum length
i believe regex in cf limitted to about 20k - Original Message - From: James Sleeman [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Thursday, January 31, 2002 10:30 PM Subject: ReReplace(NoCase) maximum length Hi All, anybody know if there is a maximum length on the string passed to ReReplace(NoCase) ? Reason I ask is that I am running the following ReReplaceNoCase(trim(text), ^HTML(.*)/HTML$, \1); and when the string in text is above a certain length (don't know how long exactly) the code fails with an Invalid regular expression message. I cut the offending text in half (it's comign from a database field (the data in the field is fine, all there, all returned in query)) and each half goes through just fine, but put em togethor and I get the error. Hopefully the designers won't mind me splitting thier page into two (stupidly long anyway) :-) --- James Sleeman __ Dedicated Windows 2000 Server PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: REReplace everything but 1-9 and a-z... what is the code please...
This will remove, or replace with blanks, all non-alphanumeric characters. CFSET str_MyVar = REReplace(str_MyVar, "[^a-zA-Z0-9]", "", "ALL") Regards, Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, October 16, 2000 8:38 PM To: CF-Talk Subject: REReplace everything but 1-9 and a-z... what is the code please... I am on a tight time line and I know I have the code somewhere... I just do not have the time right now. Could someone please email me the code to replace anything but number and letters Thanks. Vance Duke Cold Fusion Application Developer i2 Technologies (469) 357-4729 -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
Re: Rereplace and newline
I think you need to use something along the lines of chr(13) chr(10) RPS -- Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
RE: ReReplace
But, in the Excel file that is appended, I do not need the html, therefore it needs to be taken out. I would assume I use ReRlace, but I am unsure of the reg_expression that I would use. Anyone have any ideas? cfset text = REReplace(text, "[^]*", "", "All") where 'text' is your stuff. HTH, -- Rich Wild Senior Web Designer --- e-mango.com ltd Tel: 01202 587 400 Lansdowne Place Fax: 01202 587 401 17 Holdenhurst Road Bournemouth Mailto:[EMAIL PROTECTED] BH8 8EW, UK http://www.e-mango.com --- This message may contain information which is legally privileged and/or confidential. If you are not the intended recipient, you are hereby notified that any unauthorised disclosure, copying, distribution or use of this information is strictly prohibited. Such notification notwithstanding, any comments, opinions, information or conclusions expressed in this message are those of the originator, not of e-mango.com ltd, unless otherwise explicitly and independently indicated by an authorised representative of e-mango.com ltd. --- -- Archives: http://www.eGroups.com/list/cf-talk To Unsubscribe visit http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a message to [EMAIL PROTECTED] with 'unsubscribe' in the body.