title: Gatling Transforming Variables
body: <p>Following some good feedback on previous issue:</p>
  
  <p><a href="https://stackoverflow.com/questions/19546204/gatling-tool-extracting-cookie-data/19547287?iemail=1&amp;noredirect=1#19547287">Gatling-tool Extracting cookie data</a></p>
  
  <p>I have a post request in my gatling simulation which looks like the following:</p>
  
  <pre><code>.post("/checkout/onepage/form_key/${formkey}")
  </code></pre>
  
  <p>The variable ${formkey} is populated from a cookie value using:</p>
  
  <pre><code>.check(headerRegex("Set-Cookie","CACHED_FRONT_FORM_KEY=(.*)").saveAs("formkey"))
  </code></pre>
  
  <p>This appears to work correctly, however I now have an issue with:</p>
  
  <pre><code>java.net.URISyntaxException: Illegal character in path at index 90
  </code></pre>
  
  <p>Obviously I need to escape the special characters in the variable, but I'm unsure of how best to do this. </p>
  
  <p>Gatling does provide a transform function: </p>
  
  <p><a href="https://github.com/excilys/gatling/wiki/Checks#wiki-transforming" rel="nofollow noreferrer">https://github.com/excilys/gatling/wiki/Checks#wiki-transforming</a></p>
  
  <p>I'm hoping I can use this to escape the characters. Any ideas would be greatly appreciated.</p>