title: Find and Replace one list of "words" with another list of "words" pairwise in csh
body: <p>I am trying to modify some length code. I want to replace words in all words in list 1 with words in list 2 (pairwise).</p>
  
  <pre><code>List 1:
  Vsap1*(GF/(Kagf+GF))
  kdap1*AP1
  vsprb
  kpc1*pRB*E2F
  .
  .
  
  List 2:
  v1
  v2
  v3
  v4
  .
  .
  </code></pre>
  
  <p>In other words, I'd like it to replace all instances of "Vsap1*(GF/(Kagf+GF))" with "v1" (and so on) in the file "code.txt". I have List 1 in a text file ("search_for.txt").</p>
  
  <p>So far, I've been doing something like this:</p>
  
  <pre><code>set search_for=`cat search_for.txt`
  set vv=1
  
  foreach reaction $search_for
  sed -i s/$reaction/$vv/g code.txt
  set vv=$vv+1
  end
  </code></pre>
  
  <p>There are many problems with this code. First, it seems the code can't handle expression with parentheses (something about "regular expressions"?). Second, I'm not sure my counter is working properly. Third, I haven't even integrated the replace list -- I thought it would be easier to just replace with 1,2,3… instead. Ideally, I would like to replace with v1,v3,v3… </p>
  
  <p>Any help would be greatly appreciated!! I work mainly in Matlab (in which it is hard to deal with strings and such) so I'm not that great at csh.</p>
  
  <p>Best,
  Mehdi</p>