In this exercise you will implement a partial set of utility routines to help a developer clean up identifier names.
In the 4 tasks you will gradually build up the routine Clean
A valid identifier comprises
zero or more letters and underscores.
In all cases the input string is guaranteed to be non-null. If an empty string is passed to the Clean
function, an empty string should be returned.
Note that the caller should avoid calling the routine Clean
with an empty identifier since such identifiers are ineffectual.
Implement the (static) Identifier.Clean()
method to replace any spaces with underscores. This also applies to leading and trailing spaces.
Identifier.Clean("my Id");
// => "my___Id"
Modify the (static) Identifier.Clean()
method to replace control characters with the upper case string "CTRL"
.
Identifier.Clean("my\0Id");
// => "myCTRLId",
Modify the (static) Identifier.Clean()
method to convert kebab-case to camelCase.
Identifier.Clean("à-ḃç");
// => "àḂç"
Modify the (static) Identifier.Clean()
method to omit any Greek letters in the range 'α' to 'ω'.
Identifier.Clean("MyΟβιεγτFinder");
// => "MyΟFinder"