I would like to use a regular expression to mask all but the first three alphanumeric characters of each word in a string using a mask character (such as "x"), so "1 Buckingham Palace Road, London" would become "1 Bucxxxxxxx Palxxx Roax, Lonxxx".
Keeping the first three characters is easily done using
s/\b(\w{0,3})(.*)\b/$1/g
but I cannot seem to figure out how to insert length($2) times the masking character instead of $2.
Thanks!