Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript正则表达式允许使用逗号分隔的任何字符_Javascript_Regex - Fatal编程技术网

Javascript正则表达式允许使用逗号分隔的任何字符

Javascript正则表达式允许使用逗号分隔的任何字符,javascript,regex,Javascript,Regex,在Javascript中,我需要正则表达式来允许文本框中任何逗号分隔的字符 示例: 有效字符串为: ie, ch, mz en, fa, ta /path/xyz , /test/apps/ msg_abc_chec.ts, ss_msg_abc_chec.ts com.app.fr, vi.dsx;gui 909.33.33.12312:343234, 33.23.33 800x480, 200x480, 1200x1060 ,

在Javascript中,我需要正则表达式来允许文本框中任何逗号分隔的字符

示例:
有效字符串为:

ie, ch, mz
en, fa, ta
/path/xyz  , /test/apps/            
msg_abc_chec.ts, ss_msg_abc_chec.ts     
com.app.fr, vi.dsx;gui     
909.33.33.12312:343234, 33.23.33     
800x480,    200x480, 1200x1060  , 400x160      
Main app, sub app       
SomeAudOut#1   ,  SomeVidIn#3
ie,, ch, mz   - 2 commas without string
en, fa, ta,   - comma at the end
SomeAudOut#2  - no comma separated value         
无效字符串包括:

ie, ch, mz
en, fa, ta
/path/xyz  , /test/apps/            
msg_abc_chec.ts, ss_msg_abc_chec.ts     
com.app.fr, vi.dsx;gui     
909.33.33.12312:343234, 33.23.33     
800x480,    200x480, 1200x1060  , 400x160      
Main app, sub app       
SomeAudOut#1   ,  SomeVidIn#3
ie,, ch, mz   - 2 commas without string
en, fa, ta,   - comma at the end
SomeAudOut#2  - no comma separated value         
它应该与此相匹配:

((.*)+,)*
你可以用

/^(?:[^,\n]+,)+[^,\n]+$/gm

  • ^
    -行首
  • (?:[^,\n]+,)+
    -1个或多个
    • [^,\n]+,
      -1个或多个字符,而不是
      (和换行符,但仅适用于多行模式)和
  • [^,\n]+
    -1个或多个字符,而不是
    \n
    (同样,在多行模式下测试时需要
    \n
  • $
    -行末
如果您还想排除
即,ch,,mz
等行:


这里,
(?!*、\s*,)
阻止使用空格分隔的两个连续逗号的匹配行。

检查此输入是否通过:
/test/apps/,/test/apps/