Well, it is interesting that I have noticed the following:
- the first in the pattern (first parameter), I must escape $ even I though I used single quotes
- in the string value (second parameter), I must NOT escape $ even though I used single quotes
I can remember the above finding but can't understand make sense of it.
Note that the $First in the following is quoted, i.e., I am not using the value of the variable, rather, I used string "$First".
print preg_match('/\$[A-Za-z]+/', "$First")."<br>"; // match
print preg_match('/\$[A-Za-z]/', "$First")."<br>"; // match
print preg_match('/\$[A-Za-z]+/', "\$First")."<br>"; // match
print preg_match('/\$[A-Za-z]/', "\$First")."<br>"; // match
print preg_match('/\$[A-Za-z]+/', '$First')."<br>"; // match
print preg_match('/\$[A-Za-z]/', '$First')."<br>"; // match
print preg_match('/\$[A-Za-z]+/', '$First')."<br>"; // match
print preg_match('/\$[A-Za-z]/', '$First')."<br>"; // match
print preg_match('/\$[A-Za-z]+/', '\$First')."<br>"; // NO match
print preg_match('/\$[A-Za-z]*/', '\$First')."<br>"; // NO match
XB