this JS code goes towards a plugin for my forum.

the user-code for the smileys is supplied from a <span>user-code</span> or dictionary object as:

"{':\\)':'http://somedomain.com/smile.gif',':\\(':'http://somedomain.com/frown.gif'}"

^while this is user-code, a GUI replaces the textarea containing this, so the user doesn't get to see this code.

as for the code that executes the user-code on a post:

function Tcll5850_BBC_CSmileys(post, data) {
    console.log(data);
    if (data) {
        $.each(eval("("+data+")"), function(smiley, url) {
            post = post.replace(new RegExp('\\b'+smiley+'\\b', 'g'), '&nbsp;<img src="'+url+'" />&nbsp;');
        });
    };
    return post
};

where 'data' is the user code...
why doesn't RegExp('\b'+smiley+'\b', 'g') work?? O.o

I want it to work in cases where:
- the first character in the post is the start of a smiley
- the smiley is in the middle of text (and is not merged such as "8)" in "func(8):" )
- the smiley is, of course, at the end of a line

none of these cases work with the code provided

how can I fix this??

why I'm stammered about it not working...
I'm doing another project where I'm building an IDE in python using QRegExp()

the text sent through there udergoes a very similar (almost exact) method as what I'm doing here.
I'll admit I'm not a regex expert, but I do know alot about it... :/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.