Skip to main content
Inspiring
February 24, 2010
Question

Viewing matched expression in refindnocase

  • February 24, 2010
  • 1 reply
  • 870 views

Hello

I would like to know how to view the matched expressions in my refindcnocase string.

I have the following...

<cfset BODY = "The following message to  was undeliverable. The reason for the problem: 5.1.2 - Bad destination host 'DNS Hard Error looking up dirtbagshithead.com (MX) ">

<cfset hardtest= #refindnocase("500|501|502|503|504|512|523|550|551|552|553|554|5\.0\.0|5\.0\.1|5\.0\.2|5\.0\.3|5\.0\.4|5\.1\.2|5\.2\.3|5\.5\.0|5\.5\.1|5\.5\.2|5\.5\.3|5\.5\.4|hard",body)#>

BODY is the body of an email

1. I want to see if the BODY contains any of the items in the expression.

2. If it does contain one of the expressions, i want to output which one is contained.

Please can someone assist me. I would be most grateful.

best regards

Delon

    This topic has been closed for replies.

    1 reply

    Inspiring
    February 24, 2010

    OK, because the matches could be varying lengths, you will need to use the returnsubexpressions option of reFind() as as to be able to find out how long the match is, so you can extract it from the source string.  How it works is thoroughly documented here:

    http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_m-r_25.html#135102

    And:

    http://livedocs.adobe.com/coldfusion/8/htmldocs/regexp_11.html

    Also note: you do not need to use reFindNoCase() here, as you're only matching numbers.  Which intrinsically don't have a sense of case.

    --

    Adam

    Inspiring
    February 24, 2010

    Hi

    Thanks for the reply.

    I would need to use ReFindNoCase as the last experession is "hard".

    If i am incorrect, please explain..

    BEst regards

    Delon

    Inspiring
    February 24, 2010

    No, you're quite right, sorry.  Didn't spot that one.

    --

    Adam