Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part B Research online about pattern matching and regular expressions. What is a regular expression? Locate an example online and explain what it does: ____________________________

Part B

Research online about pattern matching and regular expressions.

What is a regular expression?

Locate an example online and explain what it does: ____________________________

We are going to use the following regular expression to search for a phone number: \(?\d{3}\)?[. -]? *\d{3}[. -]? *[. -]?\d{4}

What does the \d indicate?

What does the {3} indicate?

Feel free to create a form/GUI or use console to create a regular expression to determine if a phone number input is valid. You will need to import a regular expression library. My code below as an example:

string phoneNum =txtName.Text;

string MatchPhonePattern = @"\(?\d{3}\)?[. -]? *\d{3}[. -]? *[. -]?\d{4}";

Regex rx = new Regex(MatchPhonePattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);

Match match = rx.Match(phoneNum);

if (match.Success)

lblDisplay.Text = "Valid number";

else

lblDisplay.Text = "not valid";

Run your program and include a screenshot of your code running and copy and paste your code. Use phone number as a regular expression, then validate a social security number using regular expressions.

Code for Phone number regex:

Screenshot:

Code for Social Security number regex:

Screenshot:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions