Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)

I was trying to split a string something like:

'intellipaat~123 Street~Apt 2~Bangalore~IN~70005'

Can anyone help me how I can able to split this string?

1 Answer

0 votes
by (26.7k points)

You can use the split function, in able to split the string:

var input = 'intellipaat~123 Street~Apt 2~Bangalore~IN~70005';

var fields = input.split('~');

var name = fields[0];

var street = fields[1];

// etc.

I hope this will help.

Want to become a Java expert? join Java Certification now!!

Related questions

Browse Categories

...