Asheeown Posted March 31, 2009 Share Posted March 31, 2009 In a string I have multiple strings of data, each set is outlined with and opening curly bracket { and a closing curly bracket } I.e. {Var:value, var2:value2} I just need Var:value, var2:value2 in a separate variable. Quote Link to comment https://forums.phpfreaks.com/topic/151855-solved-special-characters-help/ Share on other sites More sharing options...
Asheeown Posted March 31, 2009 Author Share Posted March 31, 2009 Nvm I got it, sorry. Final code <?php preg_match_all('/(\{(.*?)\})/', $Matches[0], $Test); ?> Quote Link to comment https://forums.phpfreaks.com/topic/151855-solved-special-characters-help/#findComment-797428 Share on other sites More sharing options...
nrg_alpha Posted March 31, 2009 Share Posted March 31, 2009 nevermind I got it, sorry. Final code <?php preg_match_all('/(\{(.*?)\})/', $Matches[0], $Test); ?> Actually, you don't need to escape the curly braces, and you seem to have some additional captures in there as well that aren't needed (refering to the outer set of parenthesis). Assuming there will not be any closing curly brace till the end, you can use a negated character class and one set of capturing parenthesis instead: /{([^}]+)}/ Quote Link to comment https://forums.phpfreaks.com/topic/151855-solved-special-characters-help/#findComment-797822 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.