-1

I have a java string delimited by |-| like below.

Can't find |-| deliter based split any where else this is unique.

String agent = "iOS|-|iPhone|-|18.2.3|-|kuoipo-kjpopoo-kijhloii-kllkijii";

What is the correct regex to split the contents in string Array like below.

String[] dataarray;
dataarray[0]="iOS";
dataarray[1]="iPhone";
dataarray[2]="18.2.3";
dataarray[3]="kuoipo-kjpopoo-kijhloii-kllkijii";

Already tried:

agent.split("\\|-\\|");

Thanks in Advance.

1 Answers1

3

Won't work

agent.split("|-|")

Do

agent.split("\\|-\\|")
RAZ_Muh_Taz
  • 4,059
  • 1
  • 13
  • 26
  • That is what OP tried (see [comment to question](https://stackoverflow.com/questions/51844997/java-regex-pattern-to-split-string-based-on-delimiter-string#comment90643494_51844997)). – Andreas Aug 14 '18 at 15:39