I just wanted to update Cookie's regex to something that is a little better IMHO
code:
if (/^\/([^\s\/]\S*)\s*(.*)/.exec(sMessage) !== null) {
Cookie's old code didn't allow for / to be used elsewhere through the command (you can't use it to begin the command, but it is possible to use it later. There is no point having $ at the end of the expression due to the greedy nature of quantifiers. And finally [\s\S] is simply the equivalent of ".".
I think I should also give people an example of having parameters that are ALWAYS a single word, it is best to use the following instead:
code:
if (/^\/([^\s\/]\S*)\s*(\S*)/.exec(sMessage) !== null) {
and then for multiple paramters seperated by spaces (you will still need to do a split on the RegExp.$2 variable to get all of these variables seperated, or use of methods involving regex if you want to avoid blank variables):
code:
if (/^\/([^\s\/]\S*)\s*((?:\S+\s)*)/.exec(sMessage) !== null) {
If you want a different way to seperate between the parameters then you can use something like square braces (ie. "[param and with spaces]"). I'll use up to 3 params in this example:
code:
if (/^\/([^\s\/]\S*)\s*(?:\[.*?\]\s*(?:\[.*?\]\s*(?:\[.*?\])?)?)?/.exec(sMessage) !== null) {
This then becomes useful for when you are trying to find matching Plus! tags. But this is getting off-topic and a lot more advanced when it comes to Regex. If you have any questions, or want to see some other examples then please ask and I'll be happy to help (better to do it here so everyone can apreciate the beauty of regex)