Replace Odd Numbers of Spaces Only

in code


Stolen from Stack Overflow, this bit of regex matches odd numbers of spaces only. Last week I retabbed a work project, but didn’t catch that I replaced \t with \s instead of \s\s. Whoops.

gsed -E -i -e 's/^\s(\s\s)*/& /g' src/**/*.*

Per the SO link, x(xx)* will match odd numbers of x.

It works.




Your email address will not be published. Required fields are marked *