I don't know if this works in Jscript:
JScript code:
function startsWithToken(orig, str)
{
return new RegExp("^"+str.replace(/[\|\(\)\$\^\*\+\[\]\?]/,"\$1"),"gi").test(orig);
}
function endsWithToken(orig, str)
{
return new RegExp(str.replace(/[\|\(\)\$\^\*\+\[\]\?]/,"\$1")+"$","gi").test(orig);
}
console.log(startsWithToken("a$$","a")); // returns true;
console.log(startsWithToken("$$a","a")); // returns false;
console.log(endsWithToken("$$a","a")); // returns true;
console.log(endsWithToken("a$$","a")); // returns false;