Skate through code..
Thursday, 14 July 2016
JavaScript - Replace Comma with New Line
Use JavaScript String functions "
split
" and "
join
":
var formattedString = yourString.split(",").join("\n")
If you'd like the newlines to be HTML line breaks replace "\n" with "<br />"
Alternate method using "
replace
" function.
yourString.replace(/,/g, '\n');
2 comments:
Unknown
2 November 2020 at 00:35
ghjgj,
Reply
Delete
Replies
Reply
Unknown
14 April 2021 at 02:57
qwerty
Reply
Delete
Replies
Reply
Add comment
Load more...
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
ghjgj,
ReplyDeleteqwerty
ReplyDelete