REFindNoCase with variable length string

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default REFindNoCase with variable length string

    regexpClause = "REFindNoCase('^[0-9\-\+\(\)]{" & numLength & "}+$',str)";
    if (regexpClause) {
    return true;
    }


    It errors out saying the expression needs a constant value. as I am expecting
    1 of 2 possible string lengths I need to use a variable rather than hardcoding
    a number into the expression. Has anyone tried this before or know of a
    succesful way to do it?

    suntin Guest

  2. Similar Questions and Discussions

    1. Getting last 5 chars of variable length string
      TIA for any help on this. I have a database field that is a variable length string. I need to process some stuff IF and only if the string ends in...
    2. string length
      how do you find the length of a string in php?? there seems to be every command under the sun in the manual to operate on strings but not one for...
    3. a string length problem
      I am using Director 8 on Chinese version Windows system,a double-byte system. and I have a problem about the length of chinese character string ,...
    4. V12 length string problem
      This is my problem: i have a db (ms access) with a type "memo". In this field i have a very long text. In access i see the text correctly, but, when...
    5. How to get length of string? length() problems
      Simplified a bit, I'm parsing HTML documents to get sentences e.g. my $html = get($URL); # remove all HTML TAGs...blah blah blah @sentences =...
  3. #2

    Default Re: REFindNoCase with variable length string

    On Thu, 21 Apr 2005 06:57:05 +0000 (UTC), suntin wrote:
    > regexpClause = "REFindNoCase('^[0-9\-\+\(\)]{" & numLength & "}+$',str)";
    Can you combine {} and + as a modifier for a character set? {x} means
    exactly x times. + means one or more times. Which is it? Or does {x}+
    one or more groups of those (exactly) five chars? Regex coach says that's
    not allowed. NOt that Regex Coach is for specifically testing
    CF-implemented regexes, but it looks odd to me too.

    But let's ignore that for the time being...

    > It errors out saying the expression needs a constant value. as I am expecting
    > 1 of 2 possible string lengths
    Have you tried creating the regex as a separate string, first?

    regex = '^[0-9\-\+\(\)]{" & numLength & "}+$';
    regexpClause = "REFindNoCase(regex, str)"; // I'm guessing you're
    evaluating this at some point?

    (sorry, I'd normally test these suggestions before making them, but I'm in
    a rush to get out the door and into the sunshine today ;-)

    --

    Adam
    Adam Cameron Guest

  4. #3

    Default Re: REFindNoCase with variable length string

    ohhh, to be out in the sunshine....

    I've tried to do do the following:

    if (eval("REFindNoCase('^[0-9\-\+\(\)]{" & numLength & "}+$',str)")) {
    return true;
    }



    regexpClause = "REFindNoCase('^[0-9\-\+\(\)]{" & numLength & "}+$',str)";
    if (regexpClause) {
    return true;
    }



    regexpClause = "^[0-9\-\+\(\)]{"&numLength&"}+$";
    if (REFindNoCase(regexpClause,str)) {
    return true;
    }

    It doesn't "appear" to mind the + symbol, instead it is saying that it
    requires a constant not a variable. I fear this may be exactly as it says and
    simply a coldfusion limitation so I just ended up writing two seperate
    functions (1 for each expected string length) but oh how the good developer
    inside me weeps...

    suntin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139