Recently I ran into a case where a PHP preg_replace was no longer matching on a condition. After nearly pulling my hair out, I discovered that the problem was that the subject now had newline characters in it.
In this particular instance, I was replacing part of a SQL statement, so my preg_replace looked something like:
The above should replace everything between the "SELECT" and the "FROM clause. As it turns out, there were newline characters after each database column listed, and this cause the PHP preg_match to fail. After stripping the newline characters, the code was matching and replacing as expected.
I'm just glad we caught this during our test cycle before our next big release, as this is part of a feature that is used quite frequently by the sales team.