Moving a path item

If you want to move a path item on SVG, please note that they have a attribute d

When working with path, i want to move it. And here is my solutions:
First get current d attribute, then search for a begin point and change begin point.
var d = this.getAttribute('d');
var regExp = /^m\s?(\d.?\d),(\d.?\d)\s*/ig;
var match = regExp.exec(d);
if(match) {
var newX = +x + parseInt(match[1]); // Note x is a relative from new x position to old x position
var newY = +y + parseInt(match[2]); // Note y is a relative from new y position to old y position
var newMPoint = 'm '+parseInt(newX)+','+parseInt(newY)+' ';
var newD = d.replace(regEx,newMPoint);
this.setAttribute('d', newD);
}Demo will update soon!