Ayon Posted February 7, 2010 Share Posted February 7, 2010 I've been trying for a while now to get this regex to work, but i still haven't been able to get anything else than the curly brackets could anyone please help me out? $string = "test {id:5;name:Helbom}, test"; if (preg_match_all("/[\{(*.?)\}]/",$string,$matches)) { print_r($matches); } $smarty->display('index.tpl'); Thanks in advance Link to comment https://forums.phpfreaks.com/topic/191281-been-trying-now-but-cant-figure-this-out/ Share on other sites More sharing options...
teamatomic Posted February 7, 2010 Share Posted February 7, 2010 You dont need the square brackets, and to match everything between the curlies you need dot(anything) *(whatever follows) until the next delimiter. Also in your example string to only have one set of brackets so you dont need _all as that gives you a multi-array preg_match("/\{.*\}/",$string,$matches) HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/191281-been-trying-now-but-cant-figure-this-out/#findComment-1008557 Share on other sites More sharing options...
Ayon Posted February 7, 2010 Author Share Posted February 7, 2010 Thanks a bunch man! Link to comment https://forums.phpfreaks.com/topic/191281-been-trying-now-but-cant-figure-this-out/#findComment-1008579 Share on other sites More sharing options...
Ayon Posted February 9, 2010 Author Share Posted February 9, 2010 I was abit quick here... it's still not working as i want to i've got the following string {artist1} & {artist2} and i want to separate the to artists into an array so that i can link to each profile but for now it stores the whole string as one Link to comment https://forums.phpfreaks.com/topic/191281-been-trying-now-but-cant-figure-this-out/#findComment-1009630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.