Another String Manipulation Question

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

  1. #1

    Default Another String Manipulation Question

    Let's say I have a variable like this:

    12345432112347890

    The characters in the variable will always be different, but my goal will
    always be the same:
    Throw the first four characters into their own variable, then the next five
    into their own variable, then the next five, and finally the next three into
    their own variable.

    Any ideas?

    --
    Bill Horvath
    Community MX
    [url]http://www.communitymx.com[/url]


    Bill Guest

  2. Similar Questions and Discussions

    1. String Manipulation - Easiest Way?
      I have a field in a database that contains records that look like this: I'm trying to find the easiest (i.e. fewest lines of code) way to strip...
    2. String manipulation
      Hi! I am trying to figure out a simple, Perl way to break down any sting similar to the following: $s0 =...
    3. String Manipulation Before Posting to a Database
      Hi All: I am having difficulty with manipulating data coming from a form which is then posted to a database. The from contains a mixture of check...
    4. String manipulation and category building.
      I have been working in this problem for weeks and I was determined to sort it myself however I feel I need guidance to proceed forward. What I am...
    5. string manipulation problem - Replace
      Hi all, I'm new to ASP so this is probably a problem caused by me.... but here goes. I have been pulling some information from an access database...
  3. #2

    Default Re: Another String Manipulation Question

    This works, but it's kinda goofy:

    <cfscript>
    foo = "12345432112347890";
    bar = foo;

    varOne = Left(bar, 4);
    bar = RemoveChars(bar, 1, 4);
    varTwo = Left(bar, 5);
    bar = RemoveChars(bar, 1, 5);
    varThree = Left(bar, 5);
    bar = RemoveChars(bar, 1, 5);
    varFour = Left(bar, 3);
    </cfscript>

    cf_menace Guest

  4. #3

    Default Re: Another String Manipulation Question

    Thanks! I'll try this when I get back to the office.

    --
    Bill Horvath
    Free Tutorials for Studio MX
    [url]http://www.communitymx.com/free.cfm[/url]
    Free 10 Day Trial
    [url]http://www.communitymx.com/joincmx.cfm[/url]

    "cf_menace" <amoreno@factorsofi.com> wrote in message
    news:cv5up4$khk$1@forums.macromedia.com...
    > This works, but it's kinda goofy:
    >
    > <cfscript>
    > foo = "12345432112347890";
    > bar = foo;
    >
    > varOne = Left(bar, 4);
    > bar = RemoveChars(bar, 1, 4);
    > varTwo = Left(bar, 5);
    > bar = RemoveChars(bar, 1, 5);
    > varThree = Left(bar, 5);
    > bar = RemoveChars(bar, 1, 5);
    > varFour = Left(bar, 3);
    > </cfscript>
    >

    Bill Horvath .:CMX:. Guest

  5. #4

    Default RE: Another String Manipulation Question

    <CFSCRIPT>
    strFull = "12345432112347890";
    IF(LEN(strFull) IS 17){
    str1 = MID(strFull,1,4);
    str2 = MID(strFull,5,5);
    str3 = MID(strFull,10,5);
    str4 = MID(strFull,15,3);
    }
    </CFSCRIPT>
    Rob Guest

  6. #5

    Default Re: Another String Manipulation Question

    Wouldn't MID be a better function to use so you don't have to rewrite the bar
    variable each time??

    Zoe

    <cfscript>
    foo = "12345432112347890";

    first = mid(foo, 1, 4)
    second = mid(foo, 5, 5)
    third = mid(foo, 10, 5)
    fourth = mid(foo, 15, 3)
    </cfscript>

    zoeski80 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