--0-722892918-12054451994602 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Don't use a regexp. It isn't clear what you want to happen if there isn't a middle character if the string has a odd integer for its length. Try using some type of substring approach such as this: str xxx" str[0..str.length/2-1] + str[str.length/2,1] * 4 + str[str.length/2+1..str.length] "xxxxxx" --0-722892918-12054451994602--