+1 vote
by
There are url patterns, but regular expressions do not see the "-" sign.

Here is the code leading to the regular:
$to_match = preg_replace('/{([a-z]+):([^\}]+)}/', '(?P<\1>\2)', $to_match);
$to_match = '#^'.$to_match.'$#';

Problem: A template is given, for example item/{name:\w+} . If you go to item/item_name , then everything is fine. But if you go to item/item-name It does not find any more matches.
by
so read what \w means in the regulars, there is no hyphen.
[\w\-]+

2 Answers

0 votes
by
Try to screen out the special characters, including the hyphen, before you pass the pattern. That is, instead of this item/item-name pass it on like this: item\/item\-name
...