Of course 😉
Ok, lets look at the expression again and I'll walk you through it (actually, there was one minor mistake that I would like to correct):
$newtext = preg_replace("/<A HREF=\"([\"]*)\"/", "<A HREF=\"script.php?lang=$current_lang&file=/basedir\1\"", $message)
Now, the actual expression of course is "/<A HREF=\"([\")\"/" .. the reason that all of the quotes are escape is because the entire expression is enclosed in quotes, so to be correct in parsing any quote we use we have to escape. Now, the first / means the start of the expression. Then we match the text <A HREF=" (remember, we are escaping the quote, so when we are matching this is what it is actually looking for.) Next, we put the following if parentheses to pull it out. Now, we want to grab everything that is not a quote (") (get everything between the quotes) and pull it out. then, we say we have another quote (") and the last / ends the expression. the one minor fix is placing an i at the end to make it case insenitive (so we match <A HREF as well as <a href) ..
The same escaped quotes in the second part are true as well. So, it ending, the line you should use it:
$newtext = preg_replace("/<A HREF=\"([\"]*)\"/i", "<A HREF=\"script.php?lang=$current_lang&file=/basedir\1\"", $message)
... I don't know how you plan on handling absolute vs. relative hrefs (i.e. /directory/file vs. subdir/file) but that would need a little different approach, but I'm not sure it's necessary. If you have any other questions, feel free to ask 🙂
Chris King