I require to match first occurrence of the following pattern starting with \s or ( then NIC followed by any characters followed # or . followed by 5 or 6 digits.
Regular expression used :
preg_match('/[\\s|(]NIC.*[#|.]\d{5,6}/i', trim($test), $matches1);
Example:
$test = "(NIC.123456";// works correctly$test = "(NIC.123456 oldnic#65703 checking"// produce result(NIC.123456 oldnic#65703
But it needs to be only (NIC.123456. What is the problem?