Java – how to split strings with 𞓜

See the English answer > splitting string with pipe character ("|) 5

I separate each letter:

My code is

String strHeader="EMP ID||EMP NAME||DESIGNATION";
String[] arrStrColumnsInRow=strHeader.split("||");

How can I split it into:

Solution

use

String[] arrStrColumnsInRow=strHeader.split("\\|\\|");

This is because the parameter of split is regular expression, where | is a logical operator

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>