0

I have a page from where I get links like this:

var urls = "http://domain.com/example?p=123https://domain2.com/example?p=123..."

What I want is to separate them in Javascript/jQuery and like get an array, I tried with .slice() and more but didn't find any solution...

Example:  urls[0] --------  // Should echo "http://domain.com/example?p=123"
          urls[1] --------  // Should echo "https://domain2.com/example?p=123..."

Unfortunately I don't have access to the server... Thank you :)

2
  • 2
    urls.replace(/(https+:)/, '%%%$1').split('%%%'); should give you an array of urls. Commented Nov 4, 2015 at 18:42
  • @Teemu Thank you it works... Commented Nov 4, 2015 at 18:51

1 Answer 1

1

var urls = "http://domain.com/example?p=123https://domain2.com/example?p=123..."; urls.replace(/(https+:)/, '%%%$1').split('%%%');

The right answer is from @Teemu

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

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.