Remove part of a String
1 posts in topic
Flat View  Flat View

Posted By:   Grant_Priestley
Posted On:   Wednesday, March 13, 2002 02:23 PM


does anyone know how to remove the first part of a String..eg. the first part of a string to a certain point.

I've basically got a tracked url being..


and i want to display it as ..


The trouble lies in that the character length is a variable size with the dest="" and the clickno="" always changing

anyone with any ideas


Re: Remove part of a String

Posted By:   Anonymous  
Posted On:   Thursday, March 14, 2002 01:07 AM

If you always have the part of the string you need to extract prefixed by a fixed string (in your case seems to be "///"), you can always do something like this:

String url = "http://www.blah.com/cgi-go/dest=jguru&clickno=1234&ref=1///http://www.jguru.com";
String tracked = null;
int pos = url.lastIndexOf("///"); // you can also use indexOf()
if (pos != -1) {
tracked = url.substring(pos+3);
About | Sitemap | Contact