ohdang888 Posted February 10, 2011 Share Posted February 10, 2011 i want to find the text between "{:" and ":}", may be 1 or more instances of this i'm using this php: $str = "hello {:first_name:} ha, this is {:awesome:} haha"; $do = preg_match_all("/{.*):}/", $str, $matches); which works if theres just one instance, but when you use more than 1 instance (like the above example) it returns: first_name:} ha, this is {:awesome But i want it to return a value of first_name, AND a separate value of "awesome" ideas? thanks Quote Link to comment https://forums.phpfreaks.com/topic/227236-preg_match_all/ Share on other sites More sharing options...
requinix Posted February 10, 2011 Share Posted February 10, 2011 Use an ungreedy quantifier: .* becomes .*?. Quote Link to comment https://forums.phpfreaks.com/topic/227236-preg_match_all/#findComment-1172207 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.