Aargh. I like PHP. I love Perl regular expressions. Hence, I love preg_match and preg_replace.
Or I used to. Y'see, preg_replace has Perl's cool "evaluate the right-hand-side as though it were code" operator: 'e'. Coolness. So I write a whole mess of functions to do all sorts of cool transformations of wiki markup into HTML.
Except, if the right hand side is code, preg_replace has no consistent means of representing backreferences! Try this, kiddos:
function f($x) { print $x; }
$s = "a' \" \\b";
$s = preg_replace('/a(.*)b/e', 'f("$1")', $s);
Yeppers, it bombs. Seems that, while they remembered to escape quotes, they forgot to escape backslashes themselves. Oops.
I just wish they could treat that $1 the way Perl does it: like a variable and not like a "replace this token with the string itself"! Tell me that wouldn't make lots more sense. :-)
Thanks to the wonders of still-open PHP bug reports and very slow upgrades on virtual hosts, it looks like I'm doomed to keep my wiki engine in perpetual beta for quite a bit longer (been lingering on this for nearly two months now, no sign of relief). Other than this it's ready for release! Grr.
That was therapeutic. :-) Except it doesn't get me closer to a solution. I'm almost ready to ditch PHP altogether. Perl or Python, anyone?
