title: Java Regex BBCode not replacing but
body: <p>I am going to use the following method to replace special BB Codes for html links</p>
  
  <pre><code> public String replace(String text , String bbcode , String imageLocation ){
  
  
          StringBuffer imageBuffer = new StringBuffer (""); 
          Pattern pattern = Pattern.compile("\\"+bbcode );
          Matcher matcher = pattern.matcher(text);    
          StringBuilder builder = new StringBuilder();
          int i = 0;
          while (matcher.find()) {
              //String orginal = replacements.get(matcher.group(1));
              imageBuffer.append("&lt;img src=\"" + imageLocation + "\" /&gt;");
              String replacement = imageBuffer.toString();
              builder.append(text.substring(i, matcher.start()));
              if (replacement == null) {
                  builder.append(matcher.group(0));
              } else {
                  builder.append(replacement);
              }
              i = matcher.end();
          }
          builder.append(text.substring(i, text.length()));
          return builder.toString();
      }
  </code></pre>
  
  <p>but when it comes to replacing the following  bbcodes  , </p>
  
  <p>:D</p>
  
  <p>O:-)</p>
  
  <p>:-[</p>
  
  <p>:o) </p>
  
  <p>:~(  </p>
  
  <p>:xx(</p>
  
  <p>:-]</p>
  
  <p>:-(</p>
  
  <p>^3^ </p>
  
  <p>@_@  </p>
  
  <p>:O </p>
  
  <p>:)</p>
  
  <p>:P </p>
  
  <p>;-)</p>
  
  <p>???</p>
  
  <p>?_? </p>
  
  <p>Z_Z </p>
  
  <p>It turns out to be not closing bracket and : &lt;-- not recognized </p>
  
  <p>How should I override the regex functional code and replace the abovementioned list of icons as html image links? </p>
  
  <p>I am currently using this string array but 
  It comes out with the following error
  error: Error: No resource type specified (at '^index_6' with value '@_@').</p>
  
  <pre><code> &lt;string-array name="hkgicon_array"&gt;
          &lt;item&gt;[369]&lt;/item&gt;
          &lt;item&gt;#adore#&lt;/item&gt;
          &lt;item&gt;#yup#&lt;/item&gt;
          &lt;item&gt;#ass#&lt;/item&gt;
          &lt;item&gt;:-(&lt;/item&gt;
          &lt;item&gt;^3^&lt;/item&gt;
          &lt;item&gt;@_@&lt;/item&gt;
      &lt;/string-array&gt;
  </code></pre>