A few explanatory words: - you don't need to group the '+'-es since you're already replacing them - the character set [^+\] matches any character except a '+' (note that you don't need to escape the '+' inside a character set!) - the double + after the character set [^+] makes the regex engine to "possessively" match everything between the '+'-es. ...