Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我有一个数字,我想确保前 7 个字符是字母,下一个字符是数字。
到目前为止,我有这个可以测试字符串中的所有字符:
function HasNumbers(value) { return /[0-9]/.test(value); }
试试这个正则表达式:
/^[a-zA-Z]{7}[0-9]/
^
[a-zA-Z]{7}
[0-9]
你可以;
/^[A-Z]{7}\d{1}$/i.test( ... );