import std.math; + import std.typecons; /* - - Given a string text, replace all spaces in it with underscores, ? ---- + Given a string text, replace all spaces in it with underscores, - and if a string has more than 2 consecutive spaces, ? ---- + and if a string has more than 2 consecutive spaces, - then replace all consecutive spaces with - ? ---- + then replace all consecutive spaces with - - - >>> fix_spaces(" Example") ? ---- + >>> fix_spaces(" Example") - "Example" ? ---- + "Example" - >>> fix_spaces(" Example 1") ? ---- + >>> fix_spaces(" Example 1") - "Example_1" ? ---- + "Example_1" - >>> fix_spaces(" Example 2") ? ---- + >>> fix_spaces(" Example 2") - "_Example_2" ? ---- + "_Example_2" - >>> fix_spaces(" Example 3") ? ---- + >>> fix_spaces(" Example 3") - "_Example-3" ? ---- + "_Example-3" - */ string fix_spaces(string text)