除逗号后的引号外的任何字符的正则表达式

Tun*_*lim 1 javascript regex

我想匹配以逗号分隔的每个单词,但它不能包含像'或这样的引号"

我正在使用这个正则表达式:

^[a-zA-Z0-9][\!\[\@\\\:\;a-zA-Z0-9`_\s,]+[a-zA-Z0-9]$
Run Code Online (Sandbox Code Playgroud)

但是,它只匹配字符和数字,而不匹配符号。

输出应该是:

example,example //true
exaplle,examp@3 //true, with symbol or number
example, //false, because there is no word after comma
,example //false, because there is no word before comma
@#example&$123,&example& //true, with all character and symbol except quote
Run Code Online (Sandbox Code Playgroud)

The*_*ird 5

您可以匹配字符类中存在的 1 倍以上。然后(?:在字符类中存在的非捕获组中重复 1+ 次,前面是逗号。

^[!\[@\\:;a-zA-Z0-9`_ &$#]+(?:,[!\[@\\:;a-zA-Z0-9`_ &$#]+)+$
Run Code Online (Sandbox Code Playgroud)

正则表达式演示

请注意,您不必逃避\!\@\:\;在角色职业,那\s威力也可能与后面。