You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
davhojt 1cf114eb85
docs(java): move piscine exercises from subjects/java-piscine -> subjects/java/piscine
1 year ago
..
README.md docs(java): move piscine exercises from subjects/java-piscine -> subjects/java/piscine 1 year ago

README.md

CleanExtract

Instructions

Create a file CleanExtract.java.

You are given a single string S consisting of several substrings separated by the '|' character. Unfortunately, some of these substrings contain unnecessary characters that need to be removed in order to form a well-structured output string.

In particular, for each substring sub in S, you need to extract the portion of the string that is between the first '.' and the last '.' characters, and remove any leading or trailing white space from the extracted string. These extracted substrings should then be concatenated together using the ' ' character as a separator to form the output string.

Write a function CleanExtract to solve this problem.

Expected Functions

public class CleanExtract {
    public static String extract(String s) {
        // your code here
    }
}

Usage

Here is a possible ExerciseRunner.java to test your function :

public class ExerciseRunner {
    public static void main(String[] args) {
        System.out.println(CleanExtract.extract("The|. quick brown. | what do you ..| .fox .|. Jumps over the lazy dog. ."));
        System.out.println(CleanExtract.extract("  | Who am .I  | .love coding,  |  |.  Coding is fun . | ...  "));
    }
}

and its output :

$ javac *.java -d build
$ java -cp build ExerciseRunner
The quick brown fox Jumps over the lazy dog.
I love coding, Coding is fun.
$

Notions

String Array Conditional statement Loop statement