This question already has an answer here:
Spliting a stream containing "&|&" as delimiter
I have a stream containing more than one element and using the following separator "&|&"
String user="White, John&|&false&|&true";
I try to create an array:
final String[] elementFilters = user.split("&|&");
but it take the both pipes as one of the array elements.
I get the following elements:
elementFilters[0]="White, John";
elementFilters[1]="|";
elementFilters[2]="false";
elementFilters[3]="|";
elementFilters[4]="true";
but I just require 4 elements and pipe should not be elements of the array. Any idea?
Aucun commentaire:
Enregistrer un commentaire