[英]Regex to allow only Numbers, alphabets, hyphens - up to fixed length [on hold]
[英]Regex checking for Numbers and Alphabets
我正在嘗試匹配僅包含帶逗號數字和帶連字符的數字的字符串,
應該匹配,
22-10,3,34-2,16
22,10,3,34,2,16
22-10-3-34-2-16
23-10,6
不應該匹配,
4ABS-NTts
ABS,NT
2
任何幫助都會非常有幫助
嘗試這個:
^(?:[0-9]+[,-])+[0-9]+$
說明:
^ # Start of string
(?: # Try to match:
[0-9]+ # one or more digits
[,-] # one separator (- or ,)
)+ # once or more.
[0-9]+ # Match one or more digits
$ # End of string
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.