The best way I've found is your smilies like : P use capitals, same as : O
Then the smilie images I load up into the images/smilies folder I make 8 characters long all lowercase.
This makes sure that I never have a duplicate
Then the code to replace is :nameofsmilie:
No code will ever be duplicated for any smilies using this system

I currently have pushing 150 smilies on my board