Question about order of smilies

After submitting a post today, (no I didn’t preview), I noticed that the smilie I had intended to show, wasn’t there and another was. Like this

It took my rolleyes and made it into a smiling smilie.

I understand that I had the colon and parentheses there for the smilie, but the rolleyes was in line first.

So, how does the software decide which smilie takes precedence?

:confused:

Whichever one the scripts grab first. It’ll be similar to this in PHP:


$message =~ s/:)/ <IMG SRC="$fileurl\/smile.gif">/i;
$message =~ s/:rolleyes:/ <IMG SRC="$fileurl\/rolleyes.gif">/i;
....

So, when it hits the first line, it will scan through the text of $message, and when it finds “:)” it will replace it with “<IMG SRC=http://www.fileurl.com/smile.gif>”, so that when it gets to the second line, it will see "
:rolleyes<IMG SRC=http://www.fileurl.com/smile.gif>", and the search-and-replace will fail, so no rolleyes smiley will appear.

A while back, I threw together a very crude message board formatting previewer application; in doing so, I realised that, given the task of converting a finite set of xBoard tags to their HTML equivalent, the only practical way to do it was to take the first tag in the list, then search for it in the message text (replacing where found) until no more instances can be found, then start again with the next tag and so on.
(the ‘other’ way to do it would be to scan through the text for something that might be a tag, then check if it is one or not - not really practical at all as the code branches off to check every time it finds a [ or a : or whatever)

Anyway, with my code, if there is what appears to be two overlapping tags, it will convert whichever one it looks for first, even if this is found after a whole bunch of other tags and of course in the case of the example you gave, replacing :slight_smile: with <img src=“images/smilies/smile.gif” border=“0” alt=""> ‘breaks’ the rolleyes smilie tag by stealing the colon off the end, so that by the time it comes round to searching for rolleyes tags in the message text, there aren’t any there (well, no complete ones anyway).

I’ve had my knuckles rapped in the past about making wild speculations about the inner workings of the board, so let me say that it may be that the board software works in a way that is completely different to mine, it behaves as if it does but that may not mean anything.

So, always make sure to leave a blank space around your smilies. Or encase them in something other than parentheseses. [:dubious:] >:rolleyes:< {:eek:}

whatami, if you ask a moderator nicely, they’ll fix the coding for you, if you tell them specifically where.

(There’s another way to do it. :rolleyes:)

)

Technically, that would be encasing it in something other than parentheses, Achernar. :smiley:

…eseseses :wink:

Thanks C K, but it isn’t that big of a deal. After I saw it I just got really curious as to what the order of operations was, to put it into a math term.
I think I understand now. Thanks Q.E.D. and Mangetout!

:slight_smile:

(But you can use a real parenthesis, too :rolleyes:****)

If mine doesn’t count, yours doesn’t either. Your smilie is not surrounded directly by a parenthesis. And you could even call that a blank space, albiet a zero-width one. :wink:

Have you ever dealt with finite state automata? I just finished writing a regular expression library, so I’ve been thinking about them a lot lately. Using them, you could treat all the tags and smileys in one pass, and they’re quick unless your implementation totally sucks.

**