Skip to content

Instantly share code, notes, and snippets.

@ku
Created November 12, 2008 04:12
Show Gist options
  • Save ku/24083 to your computer and use it in GitHub Desktop.
Save ku/24083 to your computer and use it in GitHub Desktop.
xpath replace
var i = document.forms[0]["data[imageSource]"];
var exp = i.value;
function f (exp) {
var [x,s,r] = exp.split(/\s*,\s*/);
return 'concat( substring-before('+x+',"'+s+'"), "'+r+'", substring-after('+x+',"'+s+'"))';
} ;
i.value = f(exp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment