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):
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
Post a Comment