开发者

Help with JavaScript Regex

开发者 https://www.devze.com 2023-03-18 02:51 出处:网络
I need help with a R开发者_Go百科egex expression to valid an ID pattern which is 7 characters where the first position is Alpha (A-Z) and ignore case and last 6 is Numeric (0-9).

I need help with a R开发者_Go百科egex expression to valid an ID pattern which is 7 characters where the first position is Alpha (A-Z) and ignore case and last 6 is Numeric (0-9).

Example: X155230 or x155230

Thanks guys.


This should work:

/^[a-z]\d{6}$/i


You could at least do some basic research in the javascript documentation. The pattern you need is

/^[A-Za-z]\d{6}$/


This seems to find your pattern, RegExr, you just have to put it into JavaScript.

The actual Regex /^[a-zA-Z]\d{6}/i


It's quite simple:

/^[A-Z]{1}[0-9]{6}$/i
0

精彩评论

暂无评论...
验证码 换一张
取 消