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 '@'
Asked
Active
Viewed 64 times
-1
-
1You 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 Answers
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
-
1Better as a comment... and please explain a bit to him so that he can understand further... – CoderNeji Jul 08 '15 at 13:12
-
First, there are no code-tags in comments, and secondly the explanation is given in the link. – sinclair Jul 31 '15 at 22:32