开发者

PHP regex to check a string

I am looking for a PHP regex to check a string is:

  • 4 characters long
  • the 1st character is开发者_开发技巧 A-Z (capitalized alphabet)
  • the 2nd to 4th characters are numbers (0-9)

A good example is: A123

Thanks!


^[A-Z][0-9]{3}$

Explanation:

^         # start of string
[A-Z]     # one character, A-Z
[0-9]{3}  # three characters, 0-9
$         # end of string
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜