Q:

Split string has symbols(many pipes) with regex

I have string word1|word2||||word3||word4| , i tried line.split("\\|"); but this will split just one pipe what's the regex that can handle my case.

A:

You can use "\\|+" to match multiple (1 or more) pipes.
line.split("\\|+");

Ideone Demo

