dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: removing parts of the variable name

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    188
    hey all,
    if this is not clear please ask clarifying questions

    I have a variable which pulls in from an external db. Everything in the db begins with the same 3 letters followed by a number.

    ie:
    abd-12
    abd-18
    abd-25

    ie:
    bf-12
    bf-105
    bf-72

    what I need to do is then split it how do I write something to remove the first 2(or more) positions and a script to write to remove the last 3(or more) - so that:

    var="bf-12";
    varLast="12";
    varFirst="bf-";

    Thanks
    fleep

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    266

    substring

    Hi,

    You need to use substr or substring, to extract the characters you want.

    Here's an example:

    Code:
    myVar = "ABC-123";
    start = myVar.substr(0,3);
    end = myVar.substr(- 3,3);
    trace(start);
    trace(end);
    Hope this helps

    Dan.

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Posts
    188
    Thanks-perfect!

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center