TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
paula_stroud
NA
1
0
Validate User input that is read in
Oct 23 2004 4:21 PM
I want to ask the User to enter a 6 digit code, and then use regular expression to validate it. If it is not correct, then ask User to try again. Here's the start of the code . . . can anyone offer a suggestion for looping and verifying the entry? Thank you. using System.Text.RegularExpressions; int code = 0; Console.WriteLine ("Enter 6 digit number."); code = Convert.ToInt32(Console.ReadLine()); string pattern = @"\d{6}"; //must be exactly 6 digits Regex rx = new Regex(pattern); //checks the pattern MatchCollection collection = rx.Matches(code); foreach(Match m in collection) Console.WriteLine(m); // displays entry
Reply
Answers (
1
)
Artificial Intelligence in .NET
Clone a copy of System.WIndows.Forms.Panel