title: Regex java to find $foo in a text?
body: <p>How can I define a pattern in java to identify</p>
  
  <pre><code>$foo
  </code></pre>
  
  <p>as a word in a text?</p>
  
  <p>Below an example to better explain.
  I need to obtain the following result:</p>
  
  <pre><code>if word == $foo
  then
  
  $FOO yyyy -&gt; found
  $foo yyyy -&gt; found
  aaa aaaa $foo -&gt; found
  yyyy $fooxxx -&gt; not found
  yyyy $foo!!! -&gt; Found
  $fooaaaa -&gt; not found
  $foo: aaa -&gt; found
  A.foo -&gt; not found
  A .foo -&gt; not found
  A?foo -&gt; not found
  A foo -&gt; not found
  </code></pre>
  
  <p>I tried this code but it does not work:</p>
  
  <pre><code>Pattern word_pattern = Pattern.compile("\\b\\$"+word+"\\b");
  if(word_pattern.matcher(text).find()){
          System.out.println("FOUND!");
          return true;
  }else{
      System.out.println(":(");
      return false;
  }
  </code></pre>