Firstly, rex is put into stream-edit (sed) mode. The regular expression is in two parts (separated by a space) Secondly, the first sed expression means substitute (s) the captured group (?<pair>\w{2}) of 2 word-characters with the first captured group (\1) followed by a hyphen (1) done globally (g) through the field. Thirdly, the second sed expression means substitute (s) the hyphen (-) at the end ($) for nothing i.e. remove it.
... View more