title: Java regex for replacing exact match
body: <p>My java app is trying to modify the following line from a file:</p>
  
  <pre><code>static int a = 5;
  </code></pre>
  
  <p>The goal is to replace 'a' with 'mod_a'.</p>
  
  <p>Using a simple <code>string.replace(var_name, "mod" + var_name)</code> gives me the following:</p>
  
  <pre><code>stmod_atic int mod_a = 5;
  </code></pre>
  
  <p>Which is quite simply wrong. Googling around i found that you can prepend "\b" and then var_name has to represent the beginning of a word, however, <code>string.replace("\\b" + var_name, "mod" + var_name)</code> does absolutely nothing :(</p>
  
  <p>(I also tested with "\b" instead of "\b")</p>