Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2005
    Posts
    20

    Red face Unanswered: Splitting some text

    Hi Every one

    Hope some one will be able to help me with this one

    I have a table with a field called "name" which contains names in this format:
    Sirname Given Middle.

    I would like to split this in to 2 fields "sir" and "first", based on the first space in the text
    ie, "Smith John Bloggs" becomes "Smith" and "John Bloggs

    any help would be fantastic
    Cheers

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Try the next code

    PHP Code:
     whole_name "Smith John Bloggs"
     
    firstSpaceinstr(1,whole_Name" ")
     
    firstNamemid$ (wholeName,1,firstSpace-1)
     
    lastNamemid$(WholeNamefirstSpace+1len(WholeName)) 

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    whole_name = "Smith John Bloggs"
    firstSpace= instr(1,whole_Name, Chr(32))
    firstName= mid$ (wholeName,1,firstSpace-1)
    lastName= mid$(WholeName, firstSpace+1, len(WholeName))

  4. #4
    Join Date
    Aug 2005
    Posts
    20
    Thanks Buddy
    just what I was after!

Posting Permissions

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