I created a regex statement to check the format of an ID, with plans to use it to validate an input to my PHP file. In my PHP file, I have an if condition which makes use of the regex statement.
Regex statement
([1-9]{2}|50)-[0-9]{3,4}$
PHP using the regex statement
elseif(preg_match("([1-9]{2}|50)-[0-9]{3,4}$", $idstring) == false){
echo "<p>Error:</p>";
}
The if condition is supposed to be entered when the value of $idstring is not of the expected format, instead, I get an error message which says that the left curly brace (in the regex statement) is unexpected.
Error message
Parse error: syntax error, unexpected '{' in /home/username/public_html/test.php on line 33