如何验证由1个大写字母,2个小写字母和3个数字组成的输入? [英] How do i validate an input that consists of a mix of 1 uppercase letter, 2 lowercase letters and 3 digits?
问题描述
我不知道该怎么做。该代码应该验证输入的用户ID,以便有1个大写字母,2个小写字母和3个数字,例如Hap123。
我尝试过:
Dim UserId As String
昏暗长度为整数
Dim格式为字符串
Console.WriteLine(输入您的用户ID)
UserID = Console.ReadLine
WHILE长度= 6
IF格式= UCASE(左(UserID,1))& LCASE(MID(UserID,2,2))& INT(RIGHT(UserID,3))
THEN Console.WriteLine(正确的格式)
ELSE控制台.WriteLine(格式错误)
ENDIF
ENDWHILE
I' not sure how to do this. The code is supposed to validate the user id that is entered so that there is 1 upper case letter, 2 lower case letters and 3 digits,eg Hap123.
What I have tried:
Dim UserId As String
Dim Length As Integer
Dim Format As String
Console.WriteLine("Input your User ID")
UserID=Console.ReadLine
WHILE Length = 6
IF Format = UCASE(Left(UserID,1))& LCASE(MID(UserID,2,2))&INT(RIGHT(UserID,3))
THEN Console.WriteLine("Correct format")
ELSE Console.WriteLine("Wrong format")
ENDIF
ENDWHILE
推荐答案
我会使用正则表达式来验证输入字符串格式。
I would use regular expressions to validate input string formatting.
这篇关于如何验证由1个大写字母,2个小写字母和3个数字组成的输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!