How to Match Exact Word for match Simly in Chat application
<p>Hey I Have some Problem to Find Exact Imotion(Facebook) for That Smily Code..
I put my Snippat Code :</p>

<pre><code>private static final HashMap&lt;String, Integer&gt; smilyRegexMap = new HashMap&lt;String, Integer&gt;();

static{
        smilyRegexMap.put( ":-)" , R.drawable.fb_smile);
        smilyRegexMap.put( ":)",R.drawable.fb_smile);
        smilyRegexMap.put( ":-]" , R.drawable.fb_smile);

        smilyRegexMap.put( ":-(", R.drawable.fb_frown);
        smilyRegexMap.put( ":(" , R.drawable.fb_frown);
        smilyRegexMap.put( ":-[" , R.drawable.fb_frown);

        smilyRegexMap.put( ":-P" , R.drawable.fb_tounge);
        smilyRegexMap.put( ":p", R.drawable.fb_tounge);

        smilyRegexMap.put( ":-D" , R.drawable.fb_grin);
        smilyRegexMap.put( ":D" , R.drawable.fb_grin);

        smilyRegexMap.put( ":-O" , R.drawable.fb_gasp);
        smilyRegexMap.put( ":*" , R.drawable.fb_gasp);

        smilyRegexMap.put( ";-)" , R.drawable.fb_wink);
        smilyRegexMap.put( ";)" , R.drawable.fb_wink);
        smilyRegexMap.put( ":putnam:" , R.drawable.fb_putnam);   
    }
</code></pre>

<p>//=========================================================</p>

<pre><code>public static CharSequence addSmileySpans(Context ch, CharSequence your_recieved_message)
{
    //smilyRegexMap = new HashMap&lt;Integer, String&gt;();

    System.out.println("==In Spannable Function..........");
    SpannableStringBuilder builder = new SpannableStringBuilder(your_recieved_message);

    System.out.println("==================Size of Smily  : "+ smilyRegexMap.size());
    @SuppressWarnings("rawtypes")
    Iterator it = smilyRegexMap.entrySet().iterator();
    while (it.hasNext()) {
        @SuppressWarnings("rawtypes")
        Map.Entry pairs = (Map.Entry) it.next();

        Pattern mPattern = Pattern.compile((String) pairs.getKey(),Pattern.CASE_INSENSITIVE);
        Matcher matcher = mPattern.matcher(your_recieved_message);

        while (matcher.find()) {
            Bitmap smiley = BitmapFactory.decodeResource(ch.getResources(), ((Integer) pairs.getValue()));
            builder.setSpan(new ImageSpan(smiley), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
}   
    return builder;
}
</code></pre>

<p>And I have Call This Function :</p>

<pre><code>addSmileySpans(this,"Hi i m Happy :-)  ;-)  :p   :putnam:  ");
</code></pre>

<p>===>>  My Problem is That when i Enter :putnam:   then this get Result like    </p>

<p>Hi i m Happy <img src="http://i.stack.imgur.com/TGo4n.png" alt="enter image description here">  <img src="http://i.stack.imgur.com/uu8JZ.png" alt="enter image description here">  <img src="http://i.stack.imgur.com/QjUbx.png" alt="enter image description here">   <img src="http://i.stack.imgur.com/pzQLp.png" alt="enter image description here"><img src="http://i.stack.imgur.com/b1Br9.gif" alt="enter image description here"></p>

<p>//===========================================</p>

<p>Ookeyyy... Now i Use this Code  :::</p>

<pre><code>Bitmap smiley = BitmapFactory.decodeResource(ch.getResources(), ((Integer) pairs.getValue()));
Object[] spans = builder.getSpans(matcher.start(), matcher.end(), ImageSpan.class);
if (spans == null || spans.length == 0) {
   builder.setSpan(new ImageSpan(smiley), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
</code></pre>

<p>But its Give Some Error ::</p>

<p>When Enter    :putnam:
its Result is            <img src="http://i.stack.imgur.com/tXwK9.png" alt="enter image description here">utnam:</p>
