title: Regular expression with placeholders
body: <p>I've got a string like this: "Hi $namevar$ how are you?". I want to:</p>
  
  <ol>
  <li>extract the placeholder name</li>
  <li>match against this string another string, for example "Hi jhon doe how are you?"</li>
  <li>extract from the test string the "namevar" part</li>
  </ol>
  
  <p>For 1) I'm using the following code:</p>
  
  <pre><code>String my = "hi $namevar$ how are you?";
  Matcher m = Pattern.compile("\\$(\\w.*?)\\$").matcher(my);
  while (m.find()) {
      System.out.println(m.group(1));
  }
  </code></pre>
  
  <p>Any tips for 2) and 3)?</p>