Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom regex in route requirements

Tags:

yaml

symfony

I'm trying to make a route parameter match an alphanumeric value that's 3 to 15 characters long. Code looks like this:

TestBundle_new:
pattern:  /message/new/{name}
defaults: { _controller: TestBundle:Message:new }
requirements:
    name:  [a-zA-Z0-9]{2,15}

Unfortunately routing.yml fails to load. I was wondering if there is anything I can do to make this work?

like image 928
DavidW Avatar asked Jan 23 '12 05:01

DavidW


1 Answers

You need to add quotes around your pattern.

name: "[a-zA-Z0-9]{2,15}"
like image 161
Kris Wallsmith Avatar answered Sep 22 '22 01:09

Kris Wallsmith