title: Clojure replace a string with regex
body: <p>Hello I want to replace a string in a file but in a special way. </p>
  
  <p>For example I'm searching for a string like " hideMenu()" by using the regex #"\WhideMenu\W" so that it will not return some text where hideMenu is inside like "willHideMenu()". </p>
  
  <p>Well I'm using the replace function like this:</p>
  
  <pre><code>(clojure.string/replace textFile #"\WhideMenu\W" "hideMenu2")
  </code></pre>
  
  <p>But the problem is that it now replaces the first whitespace and last character of the textfile too. </p>
  
  <p>For example if there is:</p>
  
  <pre><code>function hideMenu() 
  </code></pre>
  
  <p>it will be: </p>
  
  <pre><code>functionhideMenu2)
  </code></pre>
  
  <p>Which is pretty logical but how do I use replace without loosing the first and last character? I want as result:</p>
  
  <pre><code>function hideMenu2()
  </code></pre>