Problem
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.
Einschränkungen
0 ≤ length of text ≤ 10,000
Beispiele
Beispiel 1
Eingabe:
text = "Hello World"
Erwartete Ausgabe:
expected = "hello-world"
Eingabe:
std::string text = "Hello World";
Erwartete Ausgabe:
std::string expected = "hello-world";
Eingabe:
string text = "Hello World";
Erwartete Ausgabe:
string expected = "hello-world";
Erläuterung
The space becomes a dash and letters are lowercased: "hello-world".
Beispiel 2
Eingabe:
text = "Learn To Code"
Erwartete Ausgabe:
expected = "learn--to-code"
Eingabe:
std::string text = "Learn To Code";
Erwartete Ausgabe:
std::string expected = "learn--to-code";
Eingabe:
string text = "Learn To Code";
Erwartete Ausgabe:
string expected = "learn--to-code";
Erläuterung
Each space becomes its own dash: "learn--to-code".
Referenzen
Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.