title: iMacros: Using Javascript with EVAL to replace text in a variable
body: <p>I'm using iMacros on Firefox to download my Wells Fargo PDF bank statements automatically, and give the files the name of the link, like "<strong>Statement 04/22/12 (597K)</strong>"</p>
  
  <p>However, I can't have slashes in the file name (Windows restriction...). So I'm trying to replace the <strong>forward slashes</strong> by a <strong>dash</strong>.</p>
  
  <p>Here is my iMacro below. I get an error code on the following line: </p>
  
  <pre><code>SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; s.replace(/\//g, "-");") 
  </code></pre>
  
  <p>My javascript or my Regex doesn't work, and I don't know why. I'm not strong in either language - I've tried to copy from other examples as best as I could, but with no success. If you can help, that'd be great. Thanks.</p>
  
  <pre><code>VERSION BUILD=5010424 RECORDER=CR
  ' SET !ERRORIGNORE YES
  
  TAB OPEN
  TAB T=2
  URL GOTO=https://online.wellsfargo.com/login
  TAG POS=1 TYPE=INPUT:TEXT FORM=ID:Signon ATTR=ID:username CONTENT=XXX
  SET !ENCRYPTION TMPKEY
  TAG POS=1 TYPE=INPUT:PASSWORD FORM=ID:Signon ATTR=ID:password CONTENT=XXX
  TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:Signon ATTR=NAME:continue&amp;&amp;VALUE:Sign&lt;SP&gt;On
  TAG POS=1 TYPE=A ATTR=TXT:View&lt;SP&gt;online&lt;SP&gt;statements
  
  SET !EXTRACT_TEST_POPUP NO
  
  TAG POS=1 TYPE=A ATTR=TXT:Statement&lt;SP&gt;* EXTRACT=TXT
  SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; s.replace(/\//g, "-");")    &lt;---- THIS IS THE PROBLEMATIC LINE!!!!!!!!!!!!!!
  ONDOWNLOAD FOLDER=D:\Wells&lt;SP&gt;Fargo\CREDIT&lt;SP&gt;CARD\ FILE={{!VAR1}}.pdf
  TAG POS=1 TYPE=A ATTR=TXT:Statement&lt;SP&gt;* CONTENT=EVENT:SAVETARGETAS
  
  TAB CLOSE
  </code></pre>
  
  <p>As an extra, if you know how to remove the "<strong>(597K)</strong>" with Regex in the javascript, that'd be the icing on the cake. (obviously, the value of this text string will be different for each different file, so it has to be dynamic)</p>