Use a few regex to generate slug instead

Perhaps not useful as anything other than a thought exercise but this replaces all the iteration in your original algorithm with a few regex search and replace operations.

Depending on your views on the use of regex this approach may be better or worse than before :sunglasses: