-1

How to split the following string How to split following string "LLSlotBook17-07-2015@Friday@1@10.00AM-12.00PM@10@LMV,mCWG" with ',' and '@'

  • 1
    You will find a lot of possible ways at http://stackoverflow.com/questions/3481828/how-to-split-a-string-in-java – Florian Jul 08 '15 at 13:12

2 Answers2

2

You can use String.split(regexp) function :

String[] array = "LLSlotBook17-07-2015@Friday@1@10.00AM-12.00PM@10@LMV,mCWG".split(",|@");
VLEFF
  • 533
  • 3
  • 14
0

You should prefer the String.split method as mentioned by VLef, but for the sake of completeness:

String s = "LLSlotBook17-07-2015@Friday@1@10.00AM-12.00PM@10@LMV,mCWG";
int x = s.indexOf("@");
String sub = s.substring(0, x);

will give you the first substring "LLSlotBook17-07-2015".

See: http://docs.oracle.com/javase/7/docs/api/java/lang/String.html

sinclair
  • 2,812
  • 4
  • 24
  • 53