Stephen Posted January 3, 2011 Share Posted January 3, 2011 As I am not skilled in Regex, I am having trouble with this line of code. I use this: preg_match_all('/f_[a-zA-Z0-9]*_/', $string, $match); to locate the string (including f_ and _). For example, I have a function named f_get_value_ and f_set_value_ and I would like to locate these function names. However, when I do print_r($match[0]), it returns with: Array ( [0] => f_set_ [1] => f_get_ ) Obviously it is cutting it off at the first underscore it comes across (after f_) rather than what I want it to do (cut it off at the final underscore). I cannot guarantee that there will be only 1 underscore between the words (get/set_value). There could be 2, 3, 4, or more. I am looking for a regular expression that will accomplish this goal and I thank anyone who attempts to help. Link to comment https://forums.phpfreaks.com/topic/223222-obtaining-values-between-characters/ Share on other sites More sharing options...
.josh Posted January 3, 2011 Share Posted January 3, 2011 need to add an underscore to your char class [a-zA-Z0-9_] Link to comment https://forums.phpfreaks.com/topic/223222-obtaining-values-between-characters/#findComment-1154040 Share on other sites More sharing options...
Stephen Posted January 3, 2011 Author Share Posted January 3, 2011 need to add an underscore to your char class [a-zA-Z0-9_] Thanks a lot, that worked . (off topic, but I remember you from when I frequented phpfreaks ^^) Link to comment https://forums.phpfreaks.com/topic/223222-obtaining-values-between-characters/#findComment-1154044 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.