Skip to main content
September 23, 2008
Answered

RefindNoCase

  • September 23, 2008
  • 4 replies
  • 506 views
Hello everybody,

I created a code for one of our customer. The code run just find in my sever which is ColdfusionMX. but the customer still running Coldfusion 5. When I run it at the customer sever, I get the error below. Any idea or suggestion?

====================start error
Error Diagnostic Information

An error occurred while evaluating the expression:

<cfset myIndex = REFindNoCase("\b[\w-\._]+@[\w\.-]+\.[\w+\.-]+\s*\b",body,1,"True") />

Error near line 115, column 9.

Bad regular expression
===========================End of error
    This topic has been closed for replies.
    Correct answer
    I solved the problem by rewriting the code to be as the one below in order to avoid the escape sequences

    <CFSET myIndex = REFindNoCase("([a-zA-Z_0-9-])*([.]?([[:alnum:]_-]+)*)?@([[:alnum:]\-_]+\.)+[a-zA-Z]{2,4}",string,1,"True")>

    Mamdoh

    4 replies

    Inspiring
    September 24, 2008
    > I have been trying since yesterday. Any help will be appreciated

    What have you tried, and in what way did it not work?

    Did you read the CF5 docs I pointed you at? Did you check to see if there
    were CF5 equivalents of the CFMX7 bits that CF5 doesn't support? Because
    for most of it, there are direct equivalents.

    As far as I can tell there's only one bit of your CFMX7 regex that would
    not be quite straight forward to convert to CF5.

    However I'm not going to do your work for you, so pony up with where you're
    stuck, and let's go from there.

    And "I'm stuck with the whole thing" is not a valid answer ;-)

    --
    Adam
    Correct answer
    September 27, 2008
    I solved the problem by rewriting the code to be as the one below in order to avoid the escape sequences

    <CFSET myIndex = REFindNoCase("([a-zA-Z_0-9-])*([.]?([[:alnum:]_-]+)*)?@([[:alnum:]\-_]+\.)+[a-zA-Z]{2,4}",string,1,"True")>

    Mamdoh
    September 24, 2008
    Hi Adam,

    I have been trying since yesterday. Any help will be appreciated

    Inspiring
    September 23, 2008
    > I can not tell you where or what, but CF5 had much more primitive regex
    > comprehension. You are apparently using something it does not understand.

    CF5's regex implementation doesn't support escape sequences.

    Best the OP read the docs... this is the best way to find out what is and
    isn't supported for a given version.

    http://www.adobe.com/livedocs/coldfusion/5.0/Developing_ColdFusion_Applications/regexp.htm

    --
    Adam
    September 24, 2008
    Thank you for your response. Any suggestion on how I can rewrite the code in order to make comparable with CF5?
    This code REFindNoCase("\b[\w-\._]+@[\w\.-]+\.[\w+\.-]+\s*\b",body,1,"True") /> is looking for email format in the input variable which is body in this example.

    Thank you for your help
    Inspiring
    September 23, 2008
    I can not tell you where or what, but CF5 had much more primitive regex
    comprehension. You are apparently using something it does not understand.