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
asked Jan 8, 2011 at 19:20

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.

answered Jan 8, 2011 at 19:24
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

answered Jan 8, 2011 at 19:29

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.