Use String.split() with multiple delimiters

314    Asked by AashnaSaito in Java , Asked on Jun 22, 2021

I need to split a string base on delimiter - and .. Below are my desired output.

AA.BB-CC-DD.zip ->
AA
BB
CC
DD
zip 

but my following code does not work.

private void getId(String pdfName){
    String[]tokens = pdfName.split("-\.");
}

Answered by Abhishek Shukla

Your Answer

Interviews

Parent Categories