Lowercases, replaces every run of non-alphanumeric characters with a
single -, and strips leading and trailing dashes.
Details
The collapsing is what the rest of write_by_group()'s filename scheme
rests on: because a run of separators becomes exactly one dash, a
sanitized value can contain a single - but never two consecutive ones.
That leaves -- free to mark the boundary between grouping columns
without any possibility of colliding with content.
