Все задачи
Легко Решено: 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. Следуйте условию и ограничениям выше.

Учитесь у других

Решения сообщества

Пока нет опубликованных решений. Решите задание, чтобы поделиться первым.