[英]Regex for matching a string with possible spaces at beginning and end of string with a hyphen in the middle
[英]regex alphanum without spaces at the end/beginning of the string
我有下一個正則表達式: ^[az\\d\\-,:\\s]+$
,現在我需要它來禁止字符串開頭的空格,所以我需要- /^[az\\d][az\\d\\-,:\\s]?[az\\d]$/i
。
問題:輸入的字符可能是0,1,2+,但是此正則表達式至少需要2個字符
問題:該怎么做,並允許零或一個字符?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.