What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » startsWith() and endsWith()

startsWith() and endsWith()
Author: Message:
Flippy
Junior Member
**


Posts: 29
35 / Male / Flag
Joined: Jun 2009
O.P. RE: RE: startsWith() and endsWith()
quote:
Originally posted by Mnjul
Maybe this will work..

jscript code:
function startsWithToken(orig, str)
{
    return orig.indexOf(str)===0;
}
function endsWithToken(orig, str)
{
    return orig.lastIndexOf(str)===(orig.length-str.length);
}

I'm assuming str won't be longer than orig. If str's length is exactly one char more than orig's length, then orig.length-str.length returns -1 which evaluates the expression to true.

Thanks. I didn't try it yet (will do later tonight), but I cannot guarantee that orig is longer than str. str will actually be "$$" always (at least in my script), and orig is simply the message someone receives. That message might be a simple "k" or something like that, in which case this would fail (right?).

I suppose I can always use the indexOf function to see if the message contains any "$$" in the first place, before continuing and doing this. That would probably solve the problem.


One more thing... What the hell is a triple "=" ? How does this even work lol.
06-17-2009 06:26 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
startsWith() and endsWith() - by Flippy on 06-17-2009 at 04:59 PM
RE: startsWith() and endsWith() - by Mnjul on 06-17-2009 at 05:28 PM
RE: RE: startsWith() and endsWith() - by Flippy on 06-17-2009 at 06:26 PM
RE: startsWith() and endsWith() - by CookieRevised on 06-17-2009 at 07:19 PM
RE: startsWith() and endsWith() - by Flippy on 06-17-2009 at 07:46 PM
RE: startsWith() and endsWith() - by CookieRevised on 06-17-2009 at 07:52 PM
RE: startsWith() and endsWith() - by markee on 06-18-2009 at 07:46 AM
RE: startsWith() and endsWith() - by CookieRevised on 09-22-2009 at 08:15 AM
RE: startsWith() and endsWith() - by brooooof on 09-27-2009 at 06:43 AM
RE: startsWith() and endsWith() - by jerone on 10-08-2009 at 11:40 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