get substring between two strings java

Questionsget substring between two strings java
sethbeckerman5 Staff asked 4 years ago

I have a string
String str = "start-IDK-2012-2020-end"
I would like to extract "IDK-2012-2020" this alone.

start- is common for the string
-I only want IDk and the year.

other example:
String str = "start-IDK-2012-2010-java-substring-sample"
expected: IDK-2012-2010
I tried split it dint work


View on Stack Overflow