Reputation: 289
I am getting a string from server side,which contains words separated by comma.
ex:- 09:30pm - 10.30pm,11.00pm - 12.00pm ...,...,....
I want to display it like:
09:30pm - 10.30pm,
11.00pm - 12.00pm,
...,
...,
.
.
.
How to do this? Thanks in advance.
Upvotes: 0
Views: 132
Reputation: 16223
Depending on where you're using the string, you could replace commas with either \n
or <br>
:
YourString.replace(/\,/g,",\n")
Upvotes: 1
Reputation: 1357
You have 2 options:
Option 1:
var string1 = '09:30pm - 10.30pm,11.00pm - 12.00pm';
string1 = string1.split(',').join(',\n');
Option 2:
var string2 = '09:30pm - 10.30pm,11.00pm - 12.00pm';
string2 = string2.replace(/\,/g, ',\n');
Upvotes: 1
Reputation: 180
serverResponse.split(",")
This will return an array of strings
Upvotes: 1