Click to See Complete Forum and Search --> : string manipulation


jrthor2
08-18-2008, 08:55 AM
I have the below string:

http://localhost:9009/cas/v1/TGT-8-cZfEnwMOY3UbscMSjf553dULslrlkogplMn79OCutOHgtzf3XX

I need to add "tickets/" after the v1/ in this string. How would I do this? So the string should end up looking like:

http://localhost:9009/cas/v1/tickets/TGT-8-cZfEnwMOY3UbscMSjf553dULslrlkogplMn79OCutOHgtzf3XX

Thanks!!

chazzy
08-18-2008, 09:06 AM
why not just string.split("v1/") to make the parts, then reassemble them from the array (left of v1/ and right of v1/), adding the new middle.

jrthor2
08-18-2008, 09:18 AM
Could you give me some code to help? That would be greatly appreciated!!

Thanks!

chazzy
08-18-2008, 10:11 AM
public String addV1(String value) {
String[] parts = value.split("v1/");
return parts[0]+"v1/tickets/"+parts[1];
}


Not tested, but you should get the idea.

jrthor2
08-18-2008, 01:35 PM
thanks, I actually got it working before I read the respone, but thanks for you help!