股票代码验证的正则表达式(如goog,qqq,ibm,c等)

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.

Try this

    $pattern='/[a-zA-Z.]+/';
    $s_symbol   ='TQNT';
    $s_symbol2  =   "BRK.B";
    preg_match_all($pattern,$s_symbol,$matches1);
    print_r($matches1[0]);
    preg_match_all($pattern,$s_symbol2,$matches2);
    print_r($matches2[0]);