regex - Yii url rule with regular expression -


i have rule:

'employee/renewoffer/<id_offer:\d+>;<title:.+>' => 'company/renewoffer', 

http://www.example.com/123;title-of-post

which concerns single offer , works great, how rule should if if select multiple offers. link (comma separated id's):

http://www.example.com/123,456,12,5;title-of-post

as recommended ndn, can allow commas replacing \d+ in rule [\d,]+. in other words, change rule this:

'employee/renewoffer/<id_offer:[\d,]+>;<title:.+>' => 'company/renewoffer', 

the square brackets create character class (any of characters listed inside brackets allowed). so, putting \d , , in character class, allows digit or comma match. however, solution allows digits , commas. if want more flexible, change accept character using .. instance:

'employee/renewoffer/<id_offer:.+?>;<title:.+>' => 'company/renewoffer', 

the ? after .+ makes + non-greedy. means capture little can rather as can.


Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -