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/(w{0,3})(.*)/$1/g
but I cannot seem to figure out how to insert length($2) times the masking character instead of $2.
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…