Menu

[Solved]Write Method Named Swearfilter String Text String Swear Takes Two Parameters String Contai Q37291746

Write a method named swearFilter(String text, String[] swear)that takes two parameters: a String containing some text, and anarray of Strings containing a list of “swear words”. Your methodwill return a String containing the text contained in the firstString, where each “swear word” is replaced by its first character,followed by a number of stars equal to its number of charactersminus two, followed by its last character. For example, if theswear words are “duck”, “ship”, and “whole”, and the text containsthe following story: A duck was sailing on a ship shipping wholewheat bread. Duck that SHIP!!! Your method would return: A d**k wassailing on a s**p s**pping w***e wheat bread. D**k that S**P!!!Notice that your method should recognize both uppercase andlowercase characters in a swear word. You must use regularexpressions to solve this problem while utilizing Java’s replaceAllmethod in class String.

Expert Answer


Answer to Write a method named swearFilter(String text, String[] swear) that takes two parameters: a String containing some text, … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *