I have a textbox, I want this textbox to accept alphabetical and forward slash (/) characters only.
How can I make it possible in a yii2 model?
['uri', 'match', 'pattern' => '^[a-zA-Z\s]*$']
I have used above in model. It is not working
You can use this rule code instead of your rule.
['uri', 'match', 'pattern' => '/^[a-zA-Z\/]*$/' ]
Try This One....
['uri', 'match', 'pattern' => '/^[a-zA-Z/\s]+$/']
the regex should be something like and should work with yii:
preg_match('|[a-zA-Z/]*|', $string, $matches); This is just a usage example of the regex for preg_match, of course the regex should work, not using preg_match in your case.