Results 1 to 2 of 2

Thread: substr question

  1. #1
    Join Date
    Feb 2004
    Location
    Jordan
    Posts
    137

    Unhappy Unanswered: substr question

    my brother is a student he ask me this question :
    He has a text field contains names like this
    'aaaa dddd vvv'
    'ssss mmmm oooo'
    'eeee uuuu pppp'

    he wants to split the name:
    'aaaa' 'dddd' 'vvv'
    .
    .
    etc.

    I answered like this:

    begin
    p1 := instr(field1, ' ' , 1, 1)
    p2 := instr(field1, ' ' , 1, 2)
    first_name := substr(field1, 1, p1-1);
    second_name := substr(field1, p1+1, p2-p1-1);
    third_name := substr(field1, p2+1, lenght(field1)-p2);
    end;

    its work ok ....
    but if there is more than one space togother OR
    the name contain more or less than 3 parts, the code will not work

    any other idea

    thnkx in advance

  2. #2
    Join Date
    Aug 2004
    Location
    France
    Posts
    754
    Hello,

    You can have a look at this thread, I think it might help you.

    Best Regards,

    RBARAER

Posting Permissions

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