How to extract a string between two delimiters [duplicate]
If you have just a pair of brackets ( [] ) in your string, you can use indexOf(): String str = “ABC[ This is the text to be extracted ]”; String result = str.substring(str.indexOf(“[“) + 1, str.indexOf(“]”));