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

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -