This is not as simple as it seems. Most of you are likely thinking of the regex /([A-Z])/_$1/
like I have found all over the Internet, but my particular situation is slightly more complicated. My source string contains more content that I don't want to have converted before a portion that I do.
Consider a regular setter:
public function setUserId()
Of course, this method is missing a parameter. Perhaps I have many of these methods. I'd like to convert that line into
public function setUserId($user_id)
which is a rather simple thing to consider, but not so simple as I ponder it deeper. It's similar to what Andreas_D in this thread, but with the added challenge of trying to iteratively modify the variable name...
It's probably going to be something obvious using regular expressions, but I'm still pretty new with them. Either way, I can't find a decent solution to this problem anywhere in my searches.
Edit: of course, I realize that there are no capitals in "public function" which leave it safe. But, this search & substitution will be running against blocks of code, and I want to ensure that the string I'm modified begins with "public function".