Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 961703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:23:16+00:00 2026-05-16T01:23:16+00:00

I’ve got a string containing both ints and a string. How do I split

  • 0

I’ve got a string containing both ints and a string. How do I split it into two arrays, one for ints and one for the string? I also need to maintain the order because I’m writing a file parsing system that depends on reading in and correctly splitting these strings.

EDIT: Here’s a sample input, and what I would like as output:

~Wolf 100 45 4 5

Wolf as a string in an array
and the ints in their own separate array.

EDIT: A little more info:

I’m getting five variables from the user and writing them to a file. Then, I’m reading them back in again. I need to be able to identify the numbers by the name. Now that I think about it, actually, I’m not sure splitting the string is the best way to go. Is there a way to put both ints and strings in a single array? That way I can find the name, and know that the next four ints after it belong to it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:23:17+00:00Added an answer on May 16, 2026 at 1:23 am

    Use a Dictionary(Of TKey, TValue) with a String as the key, and an Integer() array as the value. This will give you the lookup functionality you are looking for…

    Sub Main()
        Dim Input As String = "~Wolf 100 45 4 5" & Environment.NewLine & _
                              "~Racoon 500 41 9 7"
    
        Dim Dict As New Dictionary(Of String, Integer())
    
        For Each Line As String In Input.Split(Environment.NewLine)
            Dim Key As String
            Dim Values As Integer() = New Integer() {}
    
            For Each LineValue As String In Line.Split(" "c)
                Dim TryInt As Integer
    
                If Integer.TryParse(LineValue, TryInt) Then
                    ReDim Preserve Values(Values.Length)
                    Values(Values.Length - 1) = TryInt
                Else
                    Key = LineValue.Trim("~")
                End If
            Next
    
            If Not String.IsNullOrEmpty(Key) Then
                Dict.Add(Key, Values)
            End If
        Next
    
        ' How to use                             \\'
        Dim WolfVals As Integer() = Dict.Item("Wolf")
    
        For Each Int as Integer in WolfVals
            Console.WriteLine(Int)
        Next
    
        Console.Read()
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
i got an object with contents of html markup in it, for example: string
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
Specifically, suppose I start with the string string =hello \'i am \' me And
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.