I’m a beginner, but I’m pretty intuitive, and have some experience with other languages. I have a regular expression I need to evaluate as part of a preg_replace statement. I’m trying to add to some phpBB code for my own purposes. Since this is a PHP problem and not a phpBB problem, I thought it would be more appropriate to ask about it here.
I want to match only if there is a newline, space, or tab in front of the pattern.
I want to match only if there is a newline, space, tab, period, question mark, exclamation point, dash, s, or y after the pattern.
Here’s what I have so far (‘AC’ is the pattern to find):
preg_replace("/[s]AC[.-!?sys]/", $replacement, $subject)
I guess you could say this was hacked together from a number of different tutorials. As I understand it, the s will cover the newline-space-tab? The period and question mark need to be escaped? The slashes surrounding the pattern are required?
It looks like it would work. But I get an error: “Warning: preg_replace() [function.preg-replace]: Compilation failed: range out of order in character class at offset 10 in…”, and Googling tells me this is a regexp failure. Not too surprising, considering that my code doesn’t look anything like the regexps I have seen in PHP elsewhere.
Any help on this would be greatly appreciated.