How do I add the character - within the preg_match?
preg_match('#^(\w+/){0,2}\w+\.\w+$#', $string)
But it must be before the last . within the string. I’ve tried just about everything I know here. I know that the - needs to be escaped. So I tried to escape it in various places, but it’s not working 🙁
argggg
Your knowlegde that the dash needs to be escaped is incomplete.
It needs to be escaped in character classes, because it has a special meaning there, but it has no special meaning in the rest of the regex, so it needs no escaping here.