Edison Grauman Edison Grauman - 2 years ago 77
Java Question

Shorten a string to whatever is in-between colons

I have to shorten a string to what is in-between two colons. For example if the string said

hello:I am in-between:goodbye

it would result in

I am in-between

Answer Source

If you can assume that there are exactly two colons (:), you could just split by it:

String input = "hello:I am in-between:goodbye";
String result = input.split(":")[1];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download