Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.