简体   繁体   English

Javascript-逗号分隔的字母数字正则表达式

[英]Javascript - Regex for comma-separated alphanumeric

I need regex for 我需要正则表达式

validating comma separated alphanumeric String with length of 3-5 chars. 验证以逗号分隔的长度为3-5个字符的字母数字字符串。

string may or may not contain commas. 字符串可能包含也可能不包含逗号。

each string will MUST have 3 to 6 numbers and One M in the end. 每个字符串必须包含3到6个数字,最后一个1M。

example- 例-

12345M
1234M,12345M,11111M

Try this 尝试这个

var re = /^(\d{3,6}M\,)*\d{3,6}M$/

Example code 范例程式码

console.log(re.test("1234M,12345M,11111M"));  // true
console.log(re.test("12345M"));               // true
console.log(re.test("12345M,"));              // false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM