You could always use $len to find the length of the words and then output $str(_,$len(%word1)) or something like that. Though I'm sure the regex method posted works quite well also.