title: Replace var^power with pow(var,power)
body: <p>I'm writing a math app in Java that uses Javascript for scripting/input.
  I want to be able to enter, say, <code>x^2</code> and have Java replace that with <code>pow(x,2)</code> before sending to the JavaScript parser.  How can I do this type of replacement?  There might be multiple different such expressions in one code snippet, which might be one or more lines.</p>