0

Newbie question - I have a string which I'm trying to pull out all the between curley braces and after the string station=.

I have a regex like this station={(.*?)}, for a string like this:

var stationMarkers=new Array();function genateScript(){var station;station={id:"1",name:"River Street , Clerkenwell",lat:"51.52916347",long:"-0.109970527",nbBikes:"16",nbEmptyDocks:"2",installed:"true",locked:"false",temporary:"false"};var latlng = new google.maps.LatLng(station.lat ,station.long); var marker = new google.maps.Marker({position: latlng,map: map,title:station.name,station:station,icon: imageInstalled});ShowInfoBulle(marker, 0, station);stationMarkers.push(marker);station={id:"2",name:"Phillimore Gardens, Kensington",lat:"51.49960695",long:"-0.197574246",nbBikes:"28",nbEmptyDocks:"8",installed:"true",locked:"false",temporary:"false"};var latlng = new google.maps.LatLng(station.lat ,station.long); var marker = new google.maps.Marker({position: latlng,map: map,title:station.name,station:station,icon: imageInstalled});ShowInfoBulle(marker, 1, station);stationMarkers.push(marker);station={id:"3",name:"Christopher Street, Liverpool Street",lat:"51.52128377",long:"-0.084605692",nbBikes:"4",nbEmptyDocks:"27",installed:"true",locked:"false",temporary:"false"};var latlng = new google.maps.LatLng(station.lat ,station.long);

However this returns and error on PHP: Delimiter must not be alphanumeric or backslash

3
  • 1
    Did your research for that error message bring up anything enlightening? Commented Dec 18, 2014 at 23:54
  • 1
    Fair point - this is now fixed! :-) Commented Dec 18, 2014 at 23:59
  • Google is your friend (>59000 hits like this one: stackoverflow.com/questions/9602321/… ) Commented Dec 19, 2014 at 0:18

1 Answer 1

1

If you are using preg_match you need to add delimiters to the pattern parameter. i.e.:

preg_match('/' . $pattern . '/', $subject);
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.