preg_match A does not match A

I am trying to switch from using eregi in my code because it is deprecated but I’m running into problems figuring out preg_match.

I have simplified things to the easiest thing I can think of but clearly something in my code is incorrect. The way I have it written tells me A does not match A.


	$subject = "A";
	$pattern = "A";

		if (preg_match('$pattern','$subject')) {
		print "Pattern $pattern matches Subject $subject<br>";
		}
		else {
		print "$pattern did not match $subject<br>";
		}


$subject = "A"; 
$pattern = "/A/"; 

if (preg_match($pattern,$subject)) { 
	print "Pattern $pattern matches Subject $subject<br>"; 
} 
else { 
	print "$pattern did not match $subject<br>"; 
} 

That works! Thank you Raju. :slight_smile: