問題
Replace every space in text with a dash -, and convert all letters to lowercase.
Implement slugify_spaces(text).
Input
text: The text to convert.
Output
Return the converted text.
制約
0 ≤ length of text ≤ 10,000
例
例 1
入力:
text = "Hello World"
期待される出力:
expected = "hello-world"
入力:
std::string text = "Hello World";
期待される出力:
std::string expected = "hello-world";
入力:
string text = "Hello World";
期待される出力:
string expected = "hello-world";
解説
The space becomes a dash and letters are lowercased: "hello-world".
例 2
入力:
text = "Learn To Code"
期待される出力:
expected = "learn--to-code"
入力:
std::string text = "Learn To Code";
期待される出力:
std::string expected = "learn--to-code";
入力:
string text = "Learn To Code";
期待される出力:
string expected = "learn--to-code";
解説
Each space becomes its own dash: "learn--to-code".
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。