I have URL like this:

http://www.site.com/app/index.html#secret_code=gagh362%%23atg._f46&other=5449

I need to pass gagh362%%23atg._f46 part to a string. All the examples i find are for simple PHP parameter parsing and i'm having difficulties to adapt them to this case. Can someone help?

You can do this kind of thing using the indexOf and substring methods of the String class. So myUrlAsString.indexOf("secret_code=") gives the start point of that string, add 12 to get the index of the first char after it, which is where your target text is located. Use the same approach to find the end of your target (either the end of the URL string, or an "&" maybe?). Then use substring to pick out the text between those two indexes.

Thanks for help, James

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.