OK here goes. The following is off-topic, but since the problem in the original post was solved I think we’re okay to have a few off-topic words.
First, a little background. Ever since the POSIX regular expressions extension, which contains functions like
ereg(), was deprecated in PHP 5.3.0, the question of migrating existing code over to the recommended PCRE family of functions (
preg_match() and friends) has popped up regularly. To this end, the special page was added to the PHP manual aimed at mentioning the most visible differences between the two regex flavours.
The fact that this question still comes up time and time again has me intrigued, can people just not find the manual page? Does the jargon on there just go over people’s heads, when they do find the page? Answering these kinds of questions is difficult, since usually people are asking “how do I make ereg(x) into preg_match(y)?” and the same pattern of events occurs as happened here: someone kindly points the OP at the relevant page of The Manual where all answers can be found (okay that might be stretching the truth a little, but we try), the OP replies with “huh, what?” and, here’s the kicker, another kind soul chips in with a copy/paste code snippet that the OP tries, notices it works, then skips away without anyone knowing whether they really learned something or will be back tomorrow with exactly the same question for a different regex. I’m still unsure whether you, Dave, are one of those people or the type to be taught how to fish.
Back to this thread again, after pointing you in the right direction (not everyone knows where to look for pre-existing documentation/support) the hope was that you would reply either having absorbed the information or come back with “that made no sense!” and you did (though it clearly made some sense, even if you were struggling and needed a hand). Then, the helpful person (we’ve all been this person) came along and offered a copy/paste snippet tailored solely for your individual problem piece of code, with no description/explanation of any kind. This would be fine had it been an example, as you had asked, to show the concepts that you need to learn when migrating your code. However because it was a drop-in replacement, you were left with the ability to say “awesome, thanks it works!” and we’re left, as I said before, wondering whether you’ll be back again tomorrow, scratching your head over a conceptually identical problem and, the ever-present danger, expecting a quick copy/paste answer. Now, multiply this by how many people ask questions on forums like this one, on mailing lists, IRC channels, and the other avenues of support and I hope you can see why I’d rather help to teach people to find their own answers, or at the very least point them, in the right direction, rather than give them a quick fix.
Forums like these are great, both for being taught (given the chance) and for being provided with quick fixes. It’s just a shame that, in my opinion, too much of the latter steps on the toes of the former even if the OP would be a willing student if given the time to be one.
P.S. Sorry for airing the above here, but you did ask. (:
P.P.S. If you have any feedback on that particular page of the manual from a “first time reader” point of view, I would love to hear it. The manual is there for folks like you to learn from so any feedback and improvements are super-welcomed. Fire over a PM if you do.