For alphanumeric tags separated by commas?

后端 未结 1 527
庸人自扰
庸人自扰 2021-01-22 01:58

I\'m new to RegEx and JavaScript and I was wondering if anyone knew what the RegEx would be for detecting whether or not an input field contained the following type of format:

相关标签:
1条回答
  • 2021-01-22 02:29

    (?:([\w\s]+)(?:,\s*))* would get any number of tags separated by commas.

    (?:([\w\s]+)(?:,\s*)){n} would match n tags where n is an integer.

    (?:([\w\s]+)(?:,\s*)){0,n} would match 0 to n tags where n is an integer.

    In order to count the tags, you'll need to check the number of captured groups.

    0 讨论(0)
提交回复
热议问题