REEscape, new function for Railo

I happened to see a Railo JIRA ticket, suggesting to add a REEscape() function for Railo. It caught my attention, because I recently blogged about my RegExSafe() function, which does exactly the same. REEscape does sound more logical then RegExSafe, if you think about the already existent functions REFind, REReplace, and REMatch.

So, I took it upon me to create this new function for Railo, which was essentially nothing more then renaming the function, and (for now) creating an installer for it. I assume the function will become Railo core in the near future, presumably for version 3.3.

Installation

You can install the custom function by using your Railo server admin.

Go to your Server admin (default is http://localhost/railo-context/admin/server.cfm), click on Extension > Providers, and add the following url:

http://www.railodeveloper.com/ExtensionProvider.cfc

Then, go to Extension > Applications, and install the REEscape custom function.

Lastly, you have to restart Railo to be able to use the tag.

The sourcecode

Check it out here.

del.icio.us Digg StumbleUpon Facebook Technorati Fav reddit Google Bookmarks
| Viewed 5010 times
  1. Colby Litnak

    #1 by Colby Litnak - August 1, 2013 at 6:09 PM

    The code:

    REEscape('my {name} is bob')

    does not escape the curly braces for me, seems like it should. Aren't their other characters to escape as well?
  2. Paul Klinkenberg

    #2 by Paul Klinkenberg - August 1, 2013 at 9:23 PM

    Hi Colby, it indeed doesn't escape curly braces, but those are only "special" if they come after parentheses, like "(a){2}" (meaning 2 a's after eachother). And the parentheses are escaped.
    For example, this works:
    [cfset x = rereplace("hi, my {name} is bob", REEscape('my {name} is bob'), "je m'appelle Bobby")/]
    [cfdump var="#x#"/]
  3. Colby Litnak

    #3 by Colby Litnak - August 1, 2013 at 9:53 PM

    @paul,

    Thanks, I learn something new every day. Fantastic.
(will not be published)
Leave this field empty