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

user2761030
  • 1,385
  • 2
  • 20
  • 33

1 Answers1

1

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

preg_match('/' . $pattern . '/', $subject);
Maltronic
  • 1,782
  • 10
  • 21