A programmer at my office made a bit of a retarded database, so I’m stuck with a problem.
I’ve got a String I need to split into 4 parts, so I can read the data from the indexes.
The string I’ve got is this:
aimer|4-28-2-2.mp3=12###
The array I’d like to get back is:
- aimer
- 4-28-2-2.mp3
- 12
- ###
The Java code I’m currently using:
String assignmentRaw = "aimer|4-28-2-2.mp3=12###";
String[] assignmentSplit = assignmentRaw.split("\\||=");
for(String assignment : assignmentSplit)
Log.i(ElkeDagApplication.DEBUG_TAG, assignment);
And returns:
- aimer
- 4-28-2-2.mp3
- 12###
If the requirement for the last split is: a digit on the left and # on the right you can do this
(?<=\\d)is a lookbehind assertion that checks for a digit on the left(?=#)is a lookahead assertion that checks for a “#” on the right