Be careful with .+
as it will match "any" character including /
slash characters, used to separate routes.
eg: /@nY-th1nG/can/../~/go$foo-holidays
Since the requirements
parameter accepts a regular expression, for matching the hyphens I recommend using [-\w]+
instead. Which matches -a-zA-Z0-9_
1 or more times.
overview:
path: /{var}-holidays/
defaults: { _controller: AppBundle:Overview:index }
requirements:
var: [-\w]+
Allowing
/01234578247-AbC-19082-Zx-holidays
Excluding paths like /$-holidays
or /test/12-holidays
If you're expecting only digit dates, you could use [-\d]+
or for a more strict requirement on the accepted date formats \d{1,4}(-\d{1,2})?
. 0-9999 followed by optional dash and 0-99
overview:
path: /{var}-holidays/
defaults: { _controller: AppBundle:Overview:index }
requirements:
var: [-\d]+ #or \d{1,4}(-\d{1,2})?
Which will allow
/190-holidays
/190-02-holidays
Excluding paths like /2019-a-holidays
and /a-2019-holidays
If you need a specific format let me know and I will update the requirement pattern used to one that is more appropriate.