Forum Moderators: coopster
I'm trying to build a wiki syntax parser with preg_replace and arrays for the search and replace items. I've made some strides, but I'm having problems with one thing.
At one point I need to convert link names to underscored_link_names. I know a little regex and I know how to use backreferences in the replacement strings. However, in this case I need to send the backreference to a function (or at least to str_replace(), but I made myself a function called "addunderscores()" to keep the code clean).
However, I can't seem to succesfully pass a backreference to a function from preg_replace.
Is there a way to do this? I hope so, because it seems like doing it any other way is going to be 10 times as difficult and more manual.
Thanks.
It's a bit gnarly with all the escaping you have to do
True, regex's can get that way sometimes when they are a bit advanced. Don't forget there is always the preg_quote() [php.net] function that can sometimes alleviate the "gnarlyness".
And welcome to WebmasterWorld, Fuzzplug Jones.