-1

I have the following URL:

http://www.xxxxxxxxx.com/search?search_keywords=Rome%2C+Italy&country=Italy&city=Rome&date_from=2016-07-02&date_to=2016-07-05

I only need to extract Rome from the url. So far I have managed to do this:

var citySearch = $.cookie('recentSearch');
citySearch.match(/_keywords=(.+)/)[1] 

where citySearch the url.

This only returns "Rome%2C+Italy&country=Italy&city=Rome&date_from=2016-07-02&date_to=2016-07-05 "

Aessandro
  • 5,517
  • 21
  • 66
  • 139
  • Do you want `Rome` because it's the first part of the String, or because that's the value of the `city` GET variable? – David Thomas Jul 01 '16 at 13:09

1 Answers1

1

your regex is matching too much, it should work with:

var citySearch = $.cookie('recentSearch');
citySearch.match(/_keywords=(.+?)&/)[1]

This would give you "Rome%2C+Italy" which is the keyword parameter.

hope this helps

Martin Ackermann
  • 884
  • 6
  • 15