Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!