s/ ([\w]{2}) # matches a pair of letters/numbers (?!$) # matches NOT end of string (zero-width negative lookahead assertion) /$1:/giox; # replace pair with trailing colon