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.