$re = '/\"SELECT([^"]|\n|\"[^";]*\")*LIMIT([^"]|\n|\"[^";]*\")*\";/';
$str = '// blah
$SelQuery = "SELECT DISTICNT C.firstname,C.lastname,C.id as clientid,QC.category_name,QR.cid,QR.catid,QR.rhid
FROM cms_question_report QR, cms_clients C,cms_questioncategory QC ,cms_reporthistory RH
WHERE C.id=QR.cid
AND QR.rhid=RH.id
AND QR.catid=\'".$objArray[\'catid\']."\'
AND QR.catid=QC.id
AND C.id IN($SelClids)
LIMIT $page_no,$this->Limit";
$SelQuery = "SELECT DISTICNT C.firstname,C.lastname,C.id as clientid,QC.category_name,QR.cid,QR.catid,QR.rhid
FROM cms_question_report QR, cms_clients C,cms_questioncategory QC ,cms_reporthistory RH
WHERE C.id=QR.cid
AND QR.rhid=RH.id
AND QR.catid=\'".$objArray[\'catid\']."\'
AND QR.catid=QC.id
AND C.id IN($SelClids)";
"SELECT LIMIT";
LIMIT
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php