Skip to content
Advertisement

How to split the text by every second specified character?

For example, i have this string:

JavaScript

And I want to split everything in it by every second colon (:). How can I do it?

Required Output

JavaScript

Advertisement

Answer

Sure. You just have to use in-built function .split( ). Here if you have str = "Hi there Go" then on str.split(‘ ‘)you will get[‘Hi’,’there’,’Go’]` You can do the same in your case.

JavaScript
Advertisement