Search code examples
phpregexyiivalidationrules

Yii custom pattern issue


Hello all I am a newbie in the yii framework and i want to validate a textArea that it accepts multiple values in such format "active sports, head gears" comma and space separated. Can any body help me with it that what pattern should be used. with match pattern validation rule any help would be appreciated and Sorry for asking in such nonprofessional mannerism.


Solution

  • Try pattern:

    '/^\w+((, \w+)?)*$/'
    

    Examples:

    'active sports, head gears' // false
    'sports, gears'             // true
    ', '                        // false
    'head'                      // true