By far the easiest way to handle a requirement like this is to split() the string into an array, then use “splicing” to remove the element of the array (reorder it, etc...), then join() the array back together to form a new string. This is a generalized solution to the problem that can easily survive the inevitable changes and refinements, without putting anyone through “regex hell.”