title: Java regex matching
body: <p><strong>strong text</strong>I have a bunch of lines in a textfile and I want to match this <code>${ALPANUMERIC characters}</code> and replace it with <code>${SAME ALPHANUMERIC characters plus _SOMETEXT(CONSTANT)}</code>.</p>
  
  <p>I've tried this expression <code>${(.+)}</code> but it didn't work and I also don't know how to do the replace regex in java. </p>
  
  <p>thank you for your feedback</p>
  
  <p>Here is some of my code :</p>
  
  <pre><code>BufferedReader br = new BufferedReader(new FileReader(file));
          String line;
          StringBuilder sb = new StringBuilder();
  
          while ((line = br.readLine()) != null) {
              Pattern p = Pattern.compile("\\$\\{.+\\}");
              Matcher m = p.matcher(line); // get a matcher object
                 if(m.find()) {
                     System.out.println("MATCH: "+m.group());
                     //TODO
                     //REPLACE STRING
                     //THEN APPEND String Builder
                 }
              }               
  </code></pre>
  
  <p>OK this above works but it only founds my variable and not the whole line for ex here is my input :</p>
  
  <p>some text before <code>${VARIABLE_NAME}</code> some text after<br/>
  some text before <code>${VARIABLE_NAME2}</code> some text after<br/>
  some text before some text without variable some text after<br/>
  ... etc<br/></p>
  
  <p>so I just want to replace the <code>${VARIABLE_NAME}</code> or <code>${VARIABLE_NAME}</code> with <code>${VARIABLE_NAME2_SOMETHING}</code> but leave preceding and following text line as it is</p>
  
  <p>EDIT:</p>
  
  <p>I though I though of a way like this :</p>
  
  <pre><code>if(line.contains("\\${([a-zA-Z0-9 ]+)}")){
                      System.out.println(line);
                  }
  
  if(line.contains("\\$\\{.+\\}")){
                      System.out.println(line);
                  }
  </code></pre>
  
  <p>My idea was to capture the line containing this, then replace , but the regex is not ok, it works with pattern/matcher combination though.</p>
  
  <p><strong>EDIT II</strong></p>
  
  <p>I feel like I'm getting closer to the solution here, here is what I've come up with so far :</p>
  
  <pre><code>  if(line.contains("$")){
                      System.out.println(line.replaceAll("\\$\\{.+\\}", "$1" +"_SUFFIX"));
                  }
  </code></pre>
  
  <p>What I meant by <code>$1</code> is the string you just matched replace it with itself + _SUFFIX</p>