StephenMeyer
StephenMeyer

Reputation: 196

Action script 3 regular expression matching

I currently have the following action script regular expression (cut down for readability):

private var _emoticonRegEx:RegExp = /(:[)|\(thumbsup\)|<3|O_O)/g;

This is used to match strings in a chat tool and replace with various emoticons.
For example if a user enters <3 it is replace with a heart emoticon.

All string are matched except "O_O" regardless of its positioning in the regexp string.

Does anyone have any ideas as to why the string 'O_O' specifically is not matched?

Upvotes: 2

Views: 122

Answers (2)

Dub4ek
Dub4ek

Reputation: 46

\:\[\)|\(thumbsup\)|<3|O_O.

You forgot screening operation for symbols: [,),:.

Upvotes: 0

StephenMeyer
StephenMeyer

Reputation: 196

It seems this is what i was after:

/(:\[|\(thumbsup\)|<3|O_O)/g;

Needed to remove the closing bracket from the first :[ and escape the [ (Thanks Jerry)

Upvotes: 2

Related Questions