What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Just adding a couple of lines, and my script doesn't work anymore!

Just adding a couple of lines, and my script doesn't work anymore!
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Just adding a couple of lines, and my script doesn't work anymore!
Some symbols have special meanings in regular expressions (and strings). And thus you can't simply put them in, you need to escape them first. Hence:
quote:
Originally posted by foaly
did you escape the symbols that are used in regexps?


Escaping such symbols means you put the 'escape' symbol in front of them. For regular expressions (and many other subcode languages) the escape symbol is the slash: \

eg: Message = Message.replace(/\!/gi, "01010101");

Note: you must do the same for paths in strings. Or any occurence of the character \ in a string (if \ is meant to be taken as a literal character).
eg: var myPath = "C:\Documents"
will return an error, because \ is a special character (the escape symbol), so you must escape the escape symbol to make it a literal character:
eg: var myPath = "C:\\Documents"
the output of the myPath variable will be C:\Documents

--------------------

But as with many things: you can avoid the whole thing and make your script hundreds of lines and probably thousands of bytes shorter (and waaaay faster), by tackling your particular problem in the proper way:
Instead of doing a replace using regular expressions for each character, it would be way faster and shorter to simply take the decimal Ascii code (which is base 10) of the character and simply convert it into a binary code (base 2).
.-= A 'frrrrrrrituurrr' for Wacky =-.
04-01-2010 03:12 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Just adding a couple of lines, and my script doesn't work anymore! - by tj0nge on 03-31-2010 at 09:39 PM
RE: Just adding a couple of lines, and my script doesn't work anymore! - by foaly on 03-31-2010 at 09:41 PM
RE: Just adding a couple of lines, and my script doesn't work anymore! - by CookieRevised on 04-01-2010 at 03:12 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