Artificial intelligent assistant

Censor text with regex I'm currently running this command to censor an indented to-do list. sed -e 's/\(\s\+- \)\(.*\)/\1XXX/g' It's great except that I'd like the number of `X`s to match the number of matched characters. How do I do that? The correct way doesn't especially need to use sed. Current example input: - Hello World - Earth Output: - XXX - XXX Desired: - XXXXXXXXXX - XXXXX

A Perl solution:


perl -pe 's/^( *- )(.+)/$1."X"x length($2)/e'


This uses `"X" x length($2)` to get the correct number of `X`s in the replacement.

Test input:


- Hello World
- Earth
This is not - censored


output:


- XXXXXXXXXXX
- XXXXX
This is not - censored

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 8cccd9e79a35723ec5e65a9605dd7b90