validate comma separated list using regex

前端 未结 4 944
囚心锁ツ
囚心锁ツ 2021-01-17 01:23

I want to validate that the user has entered a comma separated list of words only using regex, will this work/is there a better way:

 $match = \"#^([^0-9 A-z         


        
4条回答
  •  -上瘾入骨i
    2021-01-17 02:03

    your $match gives an error. this

    $str = 'sdfbdf,wefwef,323r,dfvdfv';
    $match = "/[\S\,]+\S/";
    preg_match($match,$str,$m);
    

    can work, but why don't you use explode?

提交回复
热议问题