>_ IzzyLab

Topic breakdown

Collapsing repeats is a sed substitution in -E mode, where the left side describes "a character repeated one or more times" via the + quantifier, and the right side puts a single instance of that character. It's essential to distinguish + ("one or more") from * ("zero or more"): the latter would match the emptiness between any characters and behave unexpectedly. The second mandatory element is the g flag at the end of the command: without it sed will replace only the first match on the line, and the remaining repeats will survive.

What's checked

  1. No double spaces
  2. Text preserved

What it looks like