#C1490. Clean the Sentence
Clean the Sentence
Clean the Sentence
Given a sentence, your task is to clean it up by replacing all sequences of whitespace characters (including spaces, tabs, etc.) with a single space and removing any leading or trailing whitespace. The transformation should follow the rules below:
- If there are multiple consecutive whitespace characters, they should be replaced by a single space.
- Any whitespace at the beginning or end of the sentence should be removed.
For example, the sentence "This is a test sentence." should be transformed to "This is a test sentence."
Note: Use regex
or any equivalent string manipulation function available in your programming language. If you use regular expressions and need to represent spaces, use the LaTeX format for regular expressions (e.g., \( \s+ \)).
inputFormat
The input consists of a single line that represents the sentence to be cleaned. The input will be provided via standard input (stdin).
outputFormat
Output the cleaned sentence to standard output (stdout). There should be exactly one space between words and no extra spaces at the beginning or the end.
## sampleThis is a test sentence.
This is a test sentence.