venus
venus2y ago

venus – 20-30 Aug 16

Hey. How can I split the string , so it won't throw any empty strings?
"First\nSecond\nThird\n\nFourth".split(`\n`);

["First", "Second", "Third", "", "Fourth"]; // Remove empty string
"First\nSecond\nThird\n\nFourth".split(`\n`);

["First", "Second", "Third", "", "Fourth"]; // Remove empty string
8 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
venus
venus2y ago
I knew I can do it somehow using regex, but don't know the syntax. Thank you.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
venus
venus2y ago
this string is returned from an API, so I am unable to edit it, if you meant it that way
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
venus
venus2y ago
Oh yea Thanks for the tip.
ghardin137
ghardin1372y ago
alternatively you can just filter the resulting array
reactibot
reactibot2y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1009197469743202415