すべてのチャレンジ
簡単 0件解決済み 正答率0%

Replace Spaces With Dashes

Turn spaces into dashes to make a URL-style slug.

問題

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用に調整されています。上記の説明と制約に従ってください。

他の人の解答から学ぶ

コミュニティの解答

まだ公開された解答がありません。この課題を解いて最初の解答を共有しましょう。