I need get string follow this format (C-001 and C-001-C)
C-001 (match)
C-002C (not match)
C-003-C (match)
D-004 (not match)
This is my code
if(preg_match("/^C-[0-9]$/", $input_line, $output_array)) {
print_r($output_array);
} else {
echo "NOT MATCH";
}
But result show 3 string (C-001, C-002C, C-003-C), C-002C is wrong, how to fix it?