What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » how to use special characters in a switch

how to use special characters in a switch
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: how to use special characters in a switch
Well, you can make a regular expression which does this, but you can't use that in a switch...case block.

code:
var reQuestion = /(^|\s)question(\s|$)/si; //Create a regular expression which contains the word "question".
if(reQuestion.test(Message)) { //Test the message on the regular expression
   ChatWnd.SendMessage("Target valid!");
} else {
   ChatWnd.SendMessage("Aborting, couldn't see target.");
}
Note that I made this regular expression so it'll match the word "question" only. That means, it won't match "questions". If you want it to match any occurrence of "question", it gets much simpler. Then, you can simply use this instead of the original first line:
code:
var reQuestion = /question/i; //Create a regular expression which contains "question".

Note: In all these regular expressions, the "i" modifier was placed so they're case-insensitive. This is interesting if you capitalize the word for example. If you want it to be case-sensitive, just remove the "i" at the end. ;)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
02-07-2008 10:52 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
how to use special characters in a switch - by koen on 02-07-2008 at 09:35 AM
RE: how to use special characters in a switch - by Matti on 02-07-2008 at 10:52 AM
RE: how to use special characters in a switch - by koen on 02-07-2008 at 11:01 AM
RE: how to use special characters in a switch - by markee on 02-07-2008 at 01:13 PM
RE: how to use special characters in a switch - by Spunky on 02-07-2008 at 10:00 PM
RE: how to use special characters in a switch - by markee on 02-08-2008 at 05:28 AM
RE: how to use special characters in a switch - by Matti on 02-08-2008 at 08:22 AM
RE: how to use special characters in a switch - by Spunky on 02-08-2008 at 05:42 PM
RE: how to use special characters in a switch - by markee on 02-09-2008 at 02:13 AM
RE: how to use special characters in a switch - by Spunky on 02-09-2008 at 11:10 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On