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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Ayon Posted February 7, 2010 Author Share Posted February 7, 2010 Thanks a bunch man! Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.