Jump to content

Obtaining Values Between Characters


Stephen

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.