pouncer Posted November 30, 2006 Share Posted November 30, 2006 [code] function EmotReplace(text) { var newText; newText = text.replace(":)", '<img src="emoticons/smile.gif">'); newText = newText.replace(":-)", '<img src="emoticons/smile.gif">'); newText = newText.replace(/:O/g, '<img src="emoticons/surprised.gif">'); newText = newText.replace(/:-O/g, '<img src="emoticons/surprised.gif">'); return newText; }[/code]any way i can cut them down? and on the second one i want to display the surprised.gif on all these texts[code]:-O:O:o:-o/code]so it shud work on lowercase o as well. can someone please help me out[/code] Quote Link to comment https://forums.phpfreaks.com/topic/28939-cutting-this-replace-code-down/ Share on other sites More sharing options...
fenway Posted December 6, 2006 Share Posted December 6, 2006 your regex should be /:(-)?[oO]/, assuming that works in JS. Quote Link to comment https://forums.phpfreaks.com/topic/28939-cutting-this-replace-code-down/#findComment-135992 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.