Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Goal: To complete some methods that utilise simple regular expressions to process and validate different string formats. Please see Lecture 4 , slides 4 3

Goal: To complete some methods that utilise simple regular expressions to process and
validate different string formats. Please see Lecture 4, slides 43-53 for details on regular
expressions (regex).
Please refer to the API for lab2(and the comments within the Question02.java file) for
more information on the operation of each method (and hints).
There are two methods to complete for this question.
In the first, we will use a regex expression and a suitable replace-based method from the
String class to match and replace all digits in an input string text with the corresponding
String mask both provided as arguments to the method. The result should be the new
version of the string, which should be returned from the method.
public String replaceAllNumbers(String text, String mask)
Examples:
replaceAllNumbers("1+2=3","#")->"# + # = #"
replaceAllNumbers("I am 30 years old", "?)-> "I am 30 years old"
replaceAllNumbers("I live at 1234 Main St","*")
-> "I live at **** Main St"

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

Murach's SQL Server 2012 For Developers

Authors: Bryan Syverson, Joel Murach, Mike Murach

1st Edition

1890774693, 9781890774691

Students also viewed these Databases questions