I have a String, which contains a list of names in a specific format ("Surname" "," "Firstname") and i want to convert the string into an array.

The names are gathered from a CSV file, placed in an initial array, separated and are then formatted.

I want to put the formatted names back into an array. How would i do this?

share|improve this question

0% accept rate
4  
so what did you try so far ?? – GanGnaMStYleOverFlowErroR Jan 3 at 23:11
What have you tried? Show us your code. – MrSmith42 Jan 3 at 23:11
feedback

closed as too localized by moonwave99, Hovercraft Full Of Eels, GanGnaMStYleOverFlowErroR, bensiu, A--C Jan 4 at 0:07

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

Try this:

// remove first and last parentheses
myString = myString.substring(1, myString.length()-1); 

// split on ","
String[] names = myString.split("\",\"");
share|improve this answer
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.