For a couple of reasons, I'm looking into learning the art of pregexps. Specifically (since I don't know Perl), the PHP implementation of pregexps.
So, can anyone telll me why the following code returns "No match"?
// Perl Regular Expression test
$string = "$string beginning with a dollar sign;";
if (preg_match("/^\$/",$string)) {
echo "Match!";
} else {
echo "No match!";
}
?>
It _should_ match if the first char (first signified by ^) is an actual $ sign (as signified by the escaped dollar sign in the expression, \$). But it doesn't.
I'm thinking either it's something to do with the dollar being seen, despite it being escaped, as an end-of-string marker, or as the beginning of a PHP variable somehow.
Anybody?