Jump to content

Strings into an array


point86

Recommended Posts

Hi,

Im fairly new to javascript etc so please be patient! :D

Im have a text file which I need to split into strings, and then enter these strings into an arrray.

Thus, I have something like this:

1 hello
2 how are you
3 goodbye

I want to split this into strings (with each line being a new string) and turn this into the following:

a[0] = 'hello'
a[1] = 'how are you'
a[2] = 'goodbye'

Once in the array, the numbers in the original text become unimportant.

Now I know that this can be achieved with an arraylist and possibly a scanner(?). But I dont know the syntax to implement these constructs.

Any help would be much appreciated! :D

Thanks

Point86.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.