+ 1

A multi split with brackets question

I have a string and I want to splits these signs .,:[] I like to know how to split multiple delimiters together with the brackets? StringĀ  splitme = "mom.girl, dad:boy [ girl, aunt ] granny"; I know how to do it without a [ "brackets" if that what's it called. splitme.split("[.,:]");

12th Oct 2017, 12:25 PM
Sibusiso Mbambo
2 Answers
+ 4
..... try splitme.split("\\.|\\,|\\[|\\]|:");
12th Oct 2017, 12:37 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 1
apparently this option also works when I splitme.split([,.:\\[\\]]); but I will give you the best answer
12th Oct 2017, 1:47 PM
Sibusiso Mbambo