Results 1 to 3 of 3

Thread: Split numbers and letters from a string into arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2012
    Posts
    3

    Split numbers and letters from a string into arrays

    If I had a string that contained:

    "45 + 70 - 10"

    How could I split the numbers into an integer array, and split the operators or letters into a string array?

    Simply, I just want to separate the numbers and letters into two different arrays.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Split numbers and letters from a string into arrays

    Can you depend on the spaces? If yes then simply split the string on " " and test each element in the resulting array. If not, it gets a bit more complicated.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2012
    Posts
    3

    Re: Split numbers and letters from a string into arrays

    It works if the array is a string. Thanks.

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