I have the following String (This format for the string is generic)
abc_2012-10-18-05-37-23_prasad_hv_Complete
I want to extract only
What I understand by your question is that you want 3rd element to (n-1)th element of the String split by "_" to come as it is (where n is the length of array formed after splitting). So, the code would be like this:
import java.util.Arrays;
public class StringSplit {
public static final String test = "abc_2012-10-18-05-37-23_prasad_hv_Complete";
public static void main(String args[]){
String[] data = test.split("_");
System.out.println(Arrays.toString(data));
String aim = data[2];
for(int i=3;i