0

How do I remove everything before /post in this string below and add my own address using Javascript/JQuery

showLogo=false&showVersionInfo=false&dataFile=/post/2653785385/photoset_xml/tumblr_lepsihc2RV1qbclqg/500

I want it to appear like this:

http://mydomain.com/post/2653785385/photoset_xml/tumblr_lepsihc2RV1qbclqg/500

2 Answers 2

3
var str = 'showLogo=false&showVersionInfo=false&dataFile=/post/2653785385/photoset_xml/tumblr_lepsihc2RV1qbclqg/500';

str = 'http://mydomain.com' + str.split('&dataFile=')[1];

Example: http://jsfiddle.net/52z2z/

Here it splits the string on '&dataFile=', gets the last item in the resulting Array, and concatenates it do your domain.

Sign up to request clarification or add additional context in comments.

Comments

1

You could also do this in Javascript using regular expressions:

var url = "showLogo=false&showVersionInfo=false&dataFile=/post/2653785385/photoset_xml/tumblr_lepsihc2RV1qbclqg/500";
var matches = url.match(/dataFile=(.*)/);
var what_you_need = "http://mydomain.com" + matches[1];

HTH

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.