Lol I am so confused now, but perhaps I misunderstood the problem.
Which of these is backward? :
- the string returned by MarkPattern()
- the on-screen display of that string by BBcodeView
The log file output of post #6 indicates that MarkPattern() is not causing the backwardness (with two smileys, at least) :
Waiting for debugger to connect...
Program started.
Input string = " hello -) how is everything -) "
Output string = " hello [[SMILEY CODE]] how is everything [[SMILEY CODE]] "