I get some help in putting the correct delimiters below:
if (preg_match('/^[a-zA-Z0-9_-]+[/]{1}[a-zA-Z0-9_-]+$', $bloco)) {
....
}
I get some help in putting the correct delimiters below:
if (preg_match('/^[a-zA-Z0-9_-]+[/]{1}[a-zA-Z0-9_-]+$', $bloco)) {
....
}
You put the delimiter at the beginning of the expression, the same delimiter is missing at the end. Also, you did not escape the slash ( /
).
'/^[a-zA-Z0-9_-]+\/{1}[a-zA-Z0-9_-]+$/'
Another thing: When you require a single occurrence of a character, you do not need to use quantifiers. So, your expression would look like this:
'/^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+$/'
Finally, one last improvement: character ranges can be replaced by character classes:
So, your expression would look like this:
'/^[\w\d_-]+\/[\w\d_-]+$/'