Regex for comma separated text

后端 未结 2 1533
隐瞒了意图╮
隐瞒了意图╮ 2021-01-28 08:02

I create a text field for adding tags separated by commas. (e.g. php, jquery, js, ruby on rails) The field is like the one on stakoverflow where you add tags for posts.

2条回答
  •  一个人的身影
    2021-01-28 08:52

    OK, there are a few problems here:

    1. There is no php function called "regex_match"
    2. a function uses (), not []
    3. variables start with $. The inside of [] is an index.

    The line you posted will result in a syntax error in PHP. Since you "tested it", it means this is not really the code you used. Please post the actual code.

    About the regex, it's a good first try, but you forgot the numbers:

    /^[a-z,0-9 ]+$/i
    

提交回复
热议问题