I am using the below expression for checking the stock symbol whether it is valid or not
$s_optionPattern = "/^[a-z0-9]{1,6}\s+(?:c|call|p|put)\s+[0-9\.]+\s+[0-9]{4}[0-9]{2}[0-9]{2}$/i";
$s_symbol = "TQNT CALL 6 20120519";
$s_symbol2 = "BRK'B CALL 80 20120317";
echo "<br>--->".preg_match($s_optionPattern, $s_symbol);
echo "<br>--->".preg_match($s_optionPattern, $s_symbol2);
Here I am getting false (0) for second symbol and true for first symbol.
Is it correct if i edit the regular expression in the following manner.
$s_optionPattern = "/^[a-z0-9']{1,6}\s+(?:c|call|p|put)\s+[0-9\.]+\s+[0-9]{4}[0-9]{2}[0-9]{2}$/i";
But I am not sure it is correct or not. Can any body help me to fix this issue ?
Here some stock symbols have (dot,') characters also like BRK.B, BRK'B.
--->".preg_match($s_optionPattern, $s_symbol); echo "
--->".preg_match($s_optionPattern, $s_symbol2); – user1049997 Mar 07 '12 at 10:05