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
You can use a regex to extract the data:
String input = "abc_2012-10-18-05-37-23_prasad_hv_Complete"; String output = input.replaceAll("(?i)^[a-z]+_[^_]+_(\\w+)_[a-z]+$", "$1");