i like to split a string depending on “,” character using JavaScript
example
var mystring="1=name1,2=name2,3=name3";
need output like this
1=name1
2=name2
3=name3
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Now you have an array with
['1=name1', '2=name2', '3=name3']If you then want to output it all separated by spaces you can do:
Of course, if that’s really the ultimate goal, you could also just replace commas with spaces:
(Edit: Your original post didn’t have your intended output in a code block, so I thought you were after spaces. Fortunately, the same techniques work to get multiple lines.)