Tracks
/
Java
Java
/
Exercises
/
Squeaky Clean
Squeaky Clean

Squeaky Clean

Learning Exercise

While completing Squeaky Clean, you'll learn 1 concept

Instructions

In this exercise you will implement a partial set of utility routines to help a developer clean up SqueakyClean names.

In the 4 tasks you will gradually build up the clean method. A valid SqueakyClean name is comprised of zero or more letters and underscores.

In all cases the input string is guaranteed to be non-null. Note that the clean method should treat an empty string as valid.

1. Replace any spaces encountered with underscores

Implement the (static) SqueakyClean.clean() method to replace any spaces with underscores. This also applies to leading and trailing spaces.

SqueakyClean.clean("my   Id");
// => "my___Id"

2. Replace control characters with the upper case string "CTRL"

Modify the (static) SqueakyClean.clean() method to replace control characters with the upper case string "CTRL".

SqueakyClean.clean("my\0Id");
// => "myCTRLId",

3. Convert kebab-case to camelCase

Modify the (static) SqueakyClean.clean() method to convert kebab-case to camelCase.

SqueakyClean.clean("à-ḃç");
// => "àḂç"

4. Omit characters that are not letters

Modify the (static) SqueakyClean.clean() method to omit any characters that are not letters.

SqueakyClean.clean("a1😀2😀3😀b");
// => "ab"

5. Omit Greek lower case letters

Modify the (static) SqueakyClean.clean() method to omit any Greek letters in the range 'α' to 'ω'.

SqueakyClean.clean("MyΟβιεγτFinder");
// => "MyΟFinder"
Last updated 23 June 2022
Edit via GitHub The link opens in a new window or tab
Java Exercism

Ready to start Squeaky Clean?

Sign up to Exercism to learn and master Java with 17 concepts, 129 exercises, and real human mentoring, all for free.