After some time of inactivity concerning PlusRemote, I decided to rewrite it. It will use a new way to extract commands and arguments, and therefor many features will improve dramatically.
Using Regular Expressions it will extract agruments in a way most programmers, and hopefully everyone will understand.
code:
1: var args = new Array(Message);
2: var re = /["](?:\\"|[^"])*["]|\S+/g;
3: while((match = re.exec(Message)) != null){
4: item = match.toString().replace(/(^")|("$)/g,"").replace(/\\"/g, "\"");
5: args.push(item);
6: }
As you can see, i've learnt Regular Expressions very well, because -if i may say so myself- it's a very intelligent script that does the following:
On line 1 it will create a new array that will soon contain the decrypted commands and arguments, with args[0] being the full, unencrypted string that was used for input.
On line 2 you will find the brain behind it all. It will split the message by the spaces, but leave strings with spaces in "string with spaces"-format fully intact. And can leave, in such a string the escaped quotation marks intact also.
For example, if someone types:
code:
!command hello "my name is" "Harry \"freshman\" Johnson"
it will extract
code:
!command
hello
"my name is"
"Harry \"freshman\" Johnson"
On line 3 it will loop for every arguments found (end at line 6)
On line 4 it will clean up the arguments, removing the first and last quotation mark, and will replace every escaped quotation mark, with just a quotation mark.
On line 5 it will put every single cleaned-up argument found in the array args[]
This piece of code you may use in your script free of charge, but as a thanks I would like to be noted on the Aboutscreen of your script
PS: further updates coming...