I need to extract a number between two underscores.
This has to be dynamic.
That means , I need the string between 4th and 5th underscore from the left.
The string I need is 200
If the number always is between the 4th and the 5th, you could try to split it by _, and pick out the  element from the resulting list.
Um, 200 is between the 3rd and 4th underscores (not the 4th and 5th), if I'm reading correctly. A minor detail though; the extraction process will be essentially the same either way...
You can use split method:
String fileName = "gcw_distributor_ams_200_20180419_13_10_57.enrich";
String splittedFileName = fileName.split("_");
String requiredText = splittedFileName;
Please login first before posting an answer.