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.