title: Regex to replace function in string
body: <p>I have a string</p>
  
  <pre><code>Apply the function K(i, x&lt;=&gt;k) for more info.
  </code></pre>
  
  <p>I want to convert <code>K(i, x&lt;=&gt;k)</code> to <code>K_{i}(x&lt;&gt;k)</code>, but the arguments inside the function <code>K</code> can vary, so I guess it is something like</p>
  
  <pre><code>string.replace(/\K\([.?],[.?]\)/g, 'K_{$1}($2)')
  </code></pre>
  
  <h1>Edit</h1>
  
  <p>Sorry for the vague explanation of what the arguments for K can be. I just thought the regex would be faster if it didn't specify what the arguments could be, but just had some placeholders.</p>
  
  <p>The first argument of K can be only be numbers and letters and the second argument of K can be numbers, letters, spaces, ->, &lt;->, [], &lt;>, &amp;, | and ~, and there can never be more than 2 arguments, so the pattern is always K(something, something).</p>
  
  <p>The remaining string varies as well. So a string could also look like <code>I have a function K(i,a) and two other functions K(3,p&amp;s |r) and K(f, ~g)</code></p>