title: indexOf() vs regex for identifying special characters like $ and {
body: <p>I would like to check if a special character like <code>{</code> or <code>$</code>is present in a string or not. I used regexp but during code review I was asked to use indexOf() instead regex( as its costlier). I would like to understand how indexOf() is used to identify special characters. (I familiar that this can be done to index substring)</p>
  
  <pre><code>String photoRoot = "http://someurl/${TOKEN1}/${TOKEN2}";
  Pattern p = Pattern.compile("\\$\\{(.*?)\\}");
                      Matcher m = p.matcher(photoRoot);
                      if (m.find()) {
                          // logic to be performed
                      }
  </code></pre>