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 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 .*?. Link to comment https://forums.phpfreaks.com/topic/227236-preg_match_all/#findComment-1172207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.